Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use the following code on my site to remove php extension from links:

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

It was working fine, but my host GoDaddy upgraded their servers to Apache 2.4 and now all links return 404. How to correct this ?

share|improve this question

migrated from serverfault.com Aug 15 '13 at 17:47

This question came from our site for system and network administrators.

Have you enabled the rewrite log in apache to see what it says? – EEAA Aug 15 '13 at 16:52
Where I can find this option in GoDaddy ? – Spacedust Aug 15 '13 at 16:53
Oh, are you on their shared hosting? – EEAA Aug 15 '13 at 16:53
Yes - it's shared hosting – Spacedust Aug 15 '13 at 16:55

You may want to also shut off fastCGI with these in the .htaccess file

AddHandler x-httpd-php5-cgi .php
AddHandler x-httpd-php5-cgi .php5
share|improve this answer


Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## don't touch /forum URIs
RewriteRule ^forums/ - [L,NC]

## hide .php extension snippet

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

# To remove www header
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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