It’s 2013 and there’s no reason to have .html showing on the end of each URL on your website. There’s a simple solution to remove .html from your website to come across more professional.
You need to create an .htaccess file. In order to do that, open Notepad on your computer. In Notepad, input the following:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
In order to save the file, go to File > Save As. For the file name, call it “.htaccess” without the quotes. Change the Save As Type to “All Files.”
Once you have the file saved, upload it to your public_html folder on the server. The last thing you’ll have to do is remove .html from all of your file names.
If you have any questions or comments, please feel free to post below!
I love this that was listed. I have been telling a few of my non-tech-savvy friends about this and for the longest time they just thought I was crazy. It takes seconds to complete so anyone can do it, most just don’t know how to!
He spits out this Error:
“Forbidden
You don’t have permission to access / on this server.”
here the complete content of my .htacess:
ErrorDocument 404 /404.html
AddHandler server-parsed .html
AddDefaultCharset utf-8
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
I wonder how many people actually struggle with following instructions like this, and how many simply lack the confidence to try, for fear of breaking their website.
Thank you for this info, very useful for SEO TOO!
😀
mehnnnnn…thanks alot. it worked for me. i had a little challenge cos my site is responsive and detects devices. but i just sticked to d procedure. Its really cool.
Doesn’t work for me,
Have tried multiple versions of this code now… and I get sent to my 404 error page saying The requested URL /www/staticfm.comule.com/shows.html was not found on this server (If I remove the .html)
If I don’t remove it, it says The requested URL /www/staticfm.comule.com/shows was not found on this server.
If I remove the .html in the url in the html/navigator, I also get The requested URL /www/staticfm.comule.com/shows was not found on this server.
Can’t win?
Oh, and if I remove the .html extension in both the files on server, and html in the navigator, the pages load as just the page html, not the actual page….
If you are using wordpress please try:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ $1 [R=301,L]
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
i am using visual studio code what should i do for me it doesnt work too
Sorry I know this thread is old, but this one actually works! Cheers guys and gurls! Any ideas on how to add a trailing “/” to the end of the url e.g “www.example.com/pagename/”
Hi, whenever i try any of those i get 500 internal server error!
This works
# Make pages render without their extension
Options +MultiViews
I know this gets that same results, eg http://www.my-site.com/good-stuff and if you’re a site visitor why would you want to type in http://www.my-site.com/good-stuff.html to see if that works
Just wondering why so ideas work and not others for me?
After another 2 hours of searching i found this one which works, (no trailing slash)
RewriteEngine On
# To externally redirect /dir/foo.shtml to /dir/foo
RewriteCond %{THE_REQUEST} ^GET\s.+\.shtml [NC]
RewriteRule ^(.+)\.shtml$ /$1 [R=301,L,NC]
# To internally redirect /dir/foo to /dir/foo.shtml
RewriteCond %{REQUEST_URI} !\.shtml$ [NC]
RewriteCond %{REQUEST_FILENAME}.shtml -f
RewriteRule . %{REQUEST_URI}.shtml [L]
Awesome tip – thanks for this, took me 30 seconds!
Hi,
Is it possible to hide the index for the start site?
Like: http://www.website.com
Not: http://www.website.com/index
Thank you in advacne!
Think it has worked for me.
But no need to remove the ‘.html’ from my files
Thanks,
Tom
Great advice – works perfect!
I totally can’t get this to work.
I have a plugin that adds the .html to the end of my urls. I’ve tried using this rule with that plugin activate and de-actived.
If I type in the .html url it will redirect to the non-.html url I get the “page not found” error.
HELP.
I did all these but it’s not working.
Can u please help me and tell what I have to do….
Tried All Suggestion but not working
Hey thanks so much for this tip! Question though… will adding this script to my .htaccess file mess up any webpages that I leave with .html at the end? I don’t need to switch all my file names over right now, so i wanted to check… Also, my index page has .html at the end, but something must have been done on the server to make it default to no .html at the end – will this update mess that up? Thanks so much!
thanks mate the code works
will this effect SEO? i heard it will
Thank you so much … I was having trouble with this for so long..
All my links looked like this :- http://arktechs.net/About.html ..
But now it is all good.. I owe you big time my friend
..
All the best to you .. Cheers!!
hello sir..
My website url is..http://www.skytecsolution.com/…and it have around 40-50 pages and all pages have .html extension..but if i open the any of my webpage without writing .html extension ..it will open the same page for me..and when i created it’s sitemap it will showing me that you have 2 pages of same name..First one is .html and second one is without .HTML..
like this:-
http://www.skytecsolution.com/about.html
http://www.skytecsolution.com/about
So i want only one page without HTML extension..so that search engines might index these pages as duplicate content..so what;s is the solution..
Help me…
It’s work for me. Thanks a lot!!
Well i did that but evertime i would go to the website every page would go to the 404 page
Hi, does this work on Blogger?
Hiii,
I tried what you said but it says your file is not found. How to do that.
I have tries this and it is working;
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]