Removing file extensions in htaccess

Category: Cpanel

MtnBeachBum
Asked:
2012-06-08 5:41 pm

Hits: 806
I think I have finally figured out how to get pretty urls; www.mysite.com/about.html is showing mysite.com/about. So i think I have the htaccess file correct. My question is that Google and Bing still show all urls with .html extension. I think I have to redirect old .html sites to new urls but couldn't get it to work last night. Can anyone help me with this? I resubmitted site under new url to both Google and Bing, but i think i will still have to redirect?

Thanks

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

Scott
2012-06-08 6:30 pm
Hello MtnBeachBum,

You were on the right track, but the htaccess needed a bit of tweaking. I saved the original for you as .htaccess1 and the .htaccess file running is the modified one.

I replaced that bit of rewrite code with the following code:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.html
RewriteRule (.*)\.html$ /$1 [L,R=301]

This allows the mysite.com/about to display even if the user types in mysite.com/about.html and the Search engines redirect properly now as well.

I hope this answers your question. If you have any more questions or information specific to the issue please leave a comment below so we can further assist you.

Best Regards,
Scott M

You must login before you can post a comment about this answer.

Like this Question?

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!