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.
An
.htaccess
file is a simple ASCII file that you create with a text editor like Notepad or TextMate. It provides a way to make configuration changes on a per-directory basis.
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Source - How to remove .php, .html, .htm extensions with .htaccess
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With