Issue
I have these lines in my httpd.conf
which make the all the url as a single parameter ('name'
) and when I type an name that doesen't exist index.php is loaded properly and a 404 message is shown. But the problem is that JavaScript, CSS and other assets are not loaded.
How to load those files even if a dir/ file doesn't exists. ? I'm using relative paths
. Thanks ;)
<Directory "c:/Apache24/htdocs/public">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?name=$1 [QSA,L]
</IfModule>
</Directory>
Solution
Generally, the FallbackResource
directive is a cleaner and more performant way to achieve what you're trying to do here:
http://httpd.apache.org/docs/trunk/mod/mod_dir.html#fallbackresource
Instead of the mod_rewrite
stuff, just write this:
FallbackResource index.php
Inside the PHP script you can then turn the PATH_INFO
environment variable into whatever you're using to capture the name
argument.
Answered By - djc