How to remove ".html" from URL?

Discussion in 'Web Design and Development' started by HarryPot, Aug 30, 2012.

  1. HarryPot macrumors 6502a

    Sep 5, 2009
    I have two things I would like to change:

    1. When entering my page, the URL is displayed as I would like it to show: "".

    But whenever I return to my homepage, it adds "/index.html" to the end, so I have:

    2. Every other page shows,, or /contact.html, etc.

    I would like that the homepage never shows "/index.html", and that the rest of the pages don't show the ".html". How can I achieve this?

  2. jtara macrumors 65816

    Mar 23, 2009
    You need to configure your server. Most/all web servers have the ability (often by installing or enabling a plugin) to re-write URLs.

    Nobody can give you specific advice, though, without knowing what server you are using.
  3. rocknblogger macrumors 68020


    Apr 2, 2011
    New Jersey
    If you have an Apache server you can use a ".htaccess" file to redirect however you want. There are many tutorials on how to do this. Use Google to find them.
  4. Apple Key macrumors 6502a

    Apple Key

    Jan 4, 2012
    I believe all you need to do is change the links on your site. Instead of linking to "index.html" for the homepage, link to "/". Then for the rest of the pages on your site, put them inside of subfolders. Such that the url would be "".
  5. 960design macrumors 68030

    Apr 17, 2012
    Destin, FL
  6. HarryPot, Aug 30, 2012
    Last edited: Aug 30, 2012

    HarryPot thread starter macrumors 6502a

    Sep 5, 2009
    I see a folder named "aspnet_client".

    I did search Google and found something about .htaccess, but I have no idea how to do it. Is .htaccess a file format? How do I make one?


    OK, I created a".htaccess" and uploaded it to my server. In the same directory as index.html is.

    Inside the htaccess file I wrote:

    Options +FollowSymLinks
    RewriteEngine on
    # index.html to /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3, 9}\ /.*index\.html\ HTTP/
    RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
  7. SrWebDeveloper macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA
    If you have access to the server configuration, setting the "DirectoryIndex" (for example, in Apache) directive tells the web server which filenames are considered directory indexes and will be loaded by default in a given path even if not specified. Should be set in global portion of config but can be added to .htaccess or virtual hosts.

    DirectoryIndex index.html index.htm index.php

    Points to clarify:

    1) Make sure all your links do not include any filename specified in the directive
    2) Directory native .htaccess files with URL redirection or URI re-writing are excellent suggestions but are intended to OVERRIDE the GLOBAL settings in the config file, so if you ensure all links are set right and set DirectoryIndex globally, that will solve the fundamental issue of the OP. It will not solve issues related to dynamic link creation of course so I don't dismiss such advice entirely.

    Knowing when to do what is key to avoiding conflicts in settings.

    Hope this helps.

Share This Page