I made a rewrite that rewrote the string, site.com/foo, to site.com/?loc=foo.php. It works fine, but when I enter site.com/foo.php, instead of rewriting to site.com/?loc=foo.php.php, it rewrites to something else that shows site.com/?loc=foo.php except without CSS. I want it to rewrite it as site.com/?loc=foo.php.php.
I have an index.php that reads $loc and includes foo.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ ?loc=$1.php
Troubleshoot:
I echoed $loc on index.php and there was no feedback at all. I then echoed $loc on foo.php and found out that $loc was not declared. This leads to the conclusion that site.com/foo.php is not being rewritten for some reason in the above code.
The script you have should work fine. Here’s what I tested with.
This means:
1) You have another parameter in .htaccess that interferes. Comment out (with #) any lines other than the above. Then pull them back in, one by one (or as few as possible) until you find the culpret.
2) loc.php actually exists. the -f means “if the file does not exist”
3) When you generate $loc, you are excluding the varaible for some reason. You can check by adding the top to your index.php file. The first line shows you the get (should be ‘lol’=>’loc.php.php’) and the second line shows you all the confertions that have gone on: