Php – Removing php extension with .htaccess does not work

.htaccessapache-2.2mod-rewritePHPrewrite

I use the following code on my site elixnews.com to remove php extension from:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^\.]+)$ $1.php [NC,L]

To remove www and php extension from my links, but it doesn't work: http://elixnews.com/todays_news – What's wrong ?

Best Answer

RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

Will do the work.

Related Topic