Removing .html

by 13 replies
15
Trying to make it so you don't have to have ".html" at the end of every URL of my website to be able to access pages.

Currently, if I go to a page that doesn't have .html at the end, it's a 404 error.

I realize it has something to do with getting a .htaccess in my directory..but other than that, I have no idea what to do.

Could anyone be of assistance?

Thanks.
#programming #html #removing
  • Try this:

    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html
    You can also search via Google for htaccess remove .html extension

    The file has to be .htaccess

    You can edit it with notepad (do not use word or wordpad). Upload the file .htaccess to your webserver (in the root folder for example)
    • [2] replies
    • Micheal71 is spot on with that HTACCESS code..

      Jean-Baptiste Jung wrote a great article in CatsWhoCode.com called :
      "10 Useful htaccess snippets to have in your toolbox"

      It covers :
      • Remove www in url (eg www.domain.com becomes domain.com)
      • Prevent hotlinking of content from your website
      • Redirect all WordPress feeds to feedburner
      • Creating custom error pages
      • Force download of specific files
      • Log PHP errors
      • Remove file extensions from urls (what the OP requested here)
      • Prevent directory listing
      • Reduce pages weight by compressing static data (great for speeding up websites)
      • Automatically add utf-8 charset to files

      See the article at :

      http://www.catswhocode.com/blog/10-u...n-your-toolbox
      • [1] reply
    • So all I need to do is download the .HTACCESS file from my directory, open it with notepad, and copy/paste that coding into it. Then upload it back into my directory. Done?
      • [1] reply
  • I did just that and it still doesn't work.
  • Do I need to do this to every .htaccess in every folder of my directory?
  • Thanks to this thread I finally removed html from my links Once you have edited your htaccess using a text editor (I used Notepad++) adding the code above. All you have to do is the name the page you are working on index.htm and Bam your done

    So instead of www.yourwebsite.com/cool/index.html
    It will be www.yourwebsite.com/cool
    • [1] reply
  • Try this and it will help if you are working on linux server.

    Redirect <redirect type> <old url> <new url>
  • It's worth mentioning that server's have a set of defaults for each folder, usually "index.html", "index.htm", "index.php"

    So let's say that your document root is "/home" (this is the top level folder for your webserver as seen by an FTP program)

    When you go to the web address of "www.example.com" it will look for the following file "/home/index.html"

    So lets say that you wanted to put something at the URL of "www.example.com/stuff"

    You create the folder (via FTP) of "/home/stuff" and add the file "index.html" so the full path of the file is "/home/stuff/index.html" and when you go to "www.example.com/stuff" you call the file "/home/stuff/index.html" with the web browser.

    If you want the URL of "www.example.com/products/pickles" then create the file "/home/products/pickles/index.html"
  • I already have an index.html in that folder.

    I'm not wanting to create a new folder for every web page I have.

    I just want to get rid of .html on every URL I have.

Next Topics on Trending Feed

  • 15

    Trying to make it so you don't have to have ".html" at the end of every URL of my website to be able to access pages. Currently, if I go to a page that doesn't have .html at the end, it's a 404 error.