Jump to content
Sign in to follow this  
imgrooot

Removed .php extension in .htaccess but it's not working anymore. Do you know why?

Recommended Posts

This is so strange.  I have this bit of code that removes the .php extension from pages so that I can visit any page without typing .php at the end.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]

The above code has always worked for me before. But for some reason today it stopped working on localhost and the live server(ipage hosting).   Do you know why that might be?

Share this post


Link to post
Share on other sites

Type something random and invalid into the file and see if your site starts returning 500 errors. If not then it means your .htaccess file isn't being interpreted anymore and you should talk to your host.

Share this post


Link to post
Share on other sites

Type something random and invalid into the file and see if your site starts returning 500 errors. If not then it means your .htaccess file isn't being interpreted anymore and you should talk to your host.

 

I do get 500 errors if I add invalid code in .htaccess. So it does work.  It can't just be the live host server because I have the same issue on localhost.  Weird thing is, I have another websites with the exact same .htaccess file on localhost and they seem to work fine.

Share this post


Link to post
Share on other sites

Stuff doesn't just stop working without a reason. If your .htaccess is being parsed and you're not getting 500s as it is now then everything there should be working - unless something changed to break it.

 

So. What changed in the last couple days?

Share this post


Link to post
Share on other sites

This is very strange but it works for me.  Simply having blank spaces between each line makes it work. Like this.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^(.*)$ $1.php [L]

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.