0

This is very bizarre. I have never had this issue until now.

Basically I have a little code in .htaccess that removes the .php extension from the web pages. For some reason, it has stopped working for me. Localhost and live server give the same error if I go the webpage without .php extension. Weird thing is, I have the exact same .htaccess file being used for another site and it works perfectly fine on both localhost and same live server.

I would like to know what might be causing this? Here's the code.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
  • Did you look at your apache log? – Julie Pelletier Aug 17 '16 at 23:11
  • If you don't add any other information, no one will be able to guess what is causing your issue. – Julie Pelletier Aug 19 '16 at 17:31
0

For some reason it works if I add spacing to it like this.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^(.*)$ $1.php [L]
  • It shouldn't so that would mean there is something wrong with the file's encoding or some invisible characters. – Julie Pelletier Aug 25 '16 at 23:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.