by Volux
13 replies
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.
#html #removing
  • Profile picture of the author Michael71
    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)
    Signature

    HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
    ---
    Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

    {{ DiscussionBoard.errors[7705975].message }}
    • Profile picture of the author Bruce Hearder
      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
      {{ DiscussionBoard.errors[7707081].message }}
      • Profile picture of the author sonas
        Originally Posted by Bruce Hearder View Post

        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
        Above link showed up a Page Not Found error but found the article at the following link: 10 useful .htaccess snippets to have in your toolbox | CatsWhoCode.com
        {{ DiscussionBoard.errors[7709803].message }}
    • Profile picture of the author Volux
      Originally Posted by Michael71 View Post

      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)
      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?
      Signature

      Need a website? Forums? PM for a quote!

      {{ DiscussionBoard.errors[7707397].message }}
      • Profile picture of the author Karen Blundell
        Originally Posted by Volux View Post

        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?
        exactly!

        learning .htaccess tips and tricks comes in really handy - believe me-
        Signature
        ---------------
        {{ DiscussionBoard.errors[7708206].message }}
  • Profile picture of the author Volux
    I did just that and it still doesn't work.
    Signature

    Need a website? Forums? PM for a quote!

    {{ DiscussionBoard.errors[7709748].message }}
  • Profile picture of the author Volux
    Do I need to do this to every .htaccess in every folder of my directory?
    Signature

    Need a website? Forums? PM for a quote!

    {{ DiscussionBoard.errors[7710792].message }}
  • Profile picture of the author cashman85
    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
    {{ DiscussionBoard.errors[7711111].message }}
  • Profile picture of the author danieldot
    Try this and it will help if you are working on linux server.

    Redirect <redirect type> <old url> <new url>
    {{ DiscussionBoard.errors[7712899].message }}
  • Profile picture of the author pseudo
    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"
    {{ DiscussionBoard.errors[7712963].message }}
  • Profile picture of the author Volux
    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.
    Signature

    Need a website? Forums? PM for a quote!

    {{ DiscussionBoard.errors[7714733].message }}

Trending Topics