Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am looking for a way to remove the extensions off the end of the Url. So say for example www.example.com/about.html. This would change to www.example.com/about

I've looked around and searched for other question similar to the one i'm asking, and i have tried them and they don't work for me :C. This one in particular, looked as though it would work, and seemed quite successful among other people: How to Remove Extensions From, and Force the Trailing Slash at the End of URLs?

This is my current .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.reallygoodpie.com$ [NC]
RewriteRule ^(.*)$ http://reallygoodpie.com/$1 [R=301,L]
share|improve this question
You have it backwards. What you want is to add the .html extension to URL requests. Otherwise you would simply name your files without extension and make html the default mime-type for your server (which probably already is). –  Itai Feb 4 '13 at 1:17
add comment

1 Answer 1

up vote 2 down vote accepted

This can be done by adding the following to your .htaccess file.

Update your .htaccess file with:

#Lets puts a really good pie in the over and rewrite history
RewriteEngine On

#Really Good Pies taste better without WWW
RewriteCond %{HTTP_HOST} ^www.reallygoodpie.com$ [NC]
RewriteRule ^(.*)$ http://reallygoodpie.com/$1 [R=301,L]

#Lets make our Really Good Pies better without trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ http://reallygoodpie.com/$1 [R=301,L]

#Really Good Pie Looks Better without HTML Extensions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

Test via Firebug or Google Webmaster Tools

Be sure that you test these redirects though firebug or Google Webmaster Tools, what you need to look out for is that your pages are not REDIRECTING twice, as I believe this should work its also best practice to ensure that double redirects are not happening. In Firebug read the header information you should see 301 > then a 200 Status. If you see 301 > 301 > 200 then you know its doubling which needs resolving.

Please take notice

The comments that I've added using hash tags can be completely removed or edited I've only added those so you can label them and should you need to revisit your htaccess it makes it easier to recall what does what without to much thought.


share|improve this answer
add comment

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.