Mobile app version of vmapp.org
Login or Join
Odierno851

: Removing file extensions off the url 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

@Odierno851

Posted in: #Htaccess #Html #UrlShorteners

I am looking for a way to remove the extensions off the end of the Url. So say for example example.com/about.html. This would change to 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 ^(.*)$ reallygoodpie.com/ [R=301,L]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Odierno851

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

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 ^(.*)$ reallygoodpie.com/ [R=301,L]
#Lets make our Really Good Pies better without trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule ^(.+)/$ reallygoodpie.com/ [R=301,L]

#Really Good Pie Looks Better without HTML Extensions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ / [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.

Enjoy

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme