meme meme - 2 months ago 6
Apache Configuration Question

How do I configure routing in Apache?

How do I hide my .html files for example when I go to www.mysite.com it redirects to www.mysite.com/index.html but it hides the /\index.html so it stays as www.mysite.com but is actually www.mysite.com/index.html .
I don't really know how to explain but if you understand me can you please help, thanks.

Answer

Please write below code in your .htaccess file.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ $1 [R=301,L]

The .html will be removed from your URL using above code. Lets say your contact us page URL is www.mysite.com/contact.html so using above code it will be www.mysite.com/contact instead.