HTML image

How to Remove .html from Your URL

October 9, 2013 in Tips by Geeks Hosted  |  12 Comments

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!

Posted in Tips and tagged , , , .

12 Responses to How to Remove .html from Your URL

  1. oldans says:

    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!

  2. Jonas Dralle says:

    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

  3. Justin says:

    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.

  4. Helloworld says:

    Thank you for this info, very useful for SEO TOO!
    😀

  5. Kay says:

    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.

  6. Rhys says:

    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?

  7. Rhys says:

    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….

    • Geeks Hosted says:

      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]

  8. Sam says:

    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/”

  9. roger says:

    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?

  10. roger says:

    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]

  11. Awesome tip – thanks for this, took me 30 seconds!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>