Removing file extensions in htaccess

  • Answered
I think I have finally figured out how to get pretty urls; is showing 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?

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 to display even if the user types in 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