.htaccesshttp-redirectwindows-hosting

Window hosting on GoDaddy to redirect index.html to root


If I have a Windows server, is there any possibility I can redirect my index.html to root:

www.example.com/index.html    -> www.example.com
http://example.com/index.html -> http://example.com 

The hosting which I am currently using is not Apache, I am using a Windows server.


Solution

  • Yet another edit:

    Meta Refresh Tag

    <meta http-equiv="refresh " content="0; url=www.example.com">
    

    There are two other options we can try if the meta refresh tag just isn't working.

    Set the default document. (Simpler)

    Web.Config Settings:

    <system.webServer>
    <defaultDocument enabled="true">
        <files>
            <clear />
            <add value="index.html" />
        </files>
    </defaultDocument>
    </system.webServer>
    

    Details on setting up via web.config: Setting Default WebPage in IIS 7.5

    OR set up via IIS UI (steps 1 through 8 in the HOW TO section): https://www.iis.net/configreference/system.webserver/defaultdocument

    Create rewrite rules in IIS. (More difficult)

    If we were using Apache, we would create/update the .htaccess file rules:

    RewriteEngine On
    RewriteRule ^index\.html$ / [R=301,L]
    RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
    

    In IIS, we have to add these rewrite rules in a different way in the web.config. See the following links.

    Steps for creating rewrite rules in web.config: IIS URL Rewrite and Web.config

    Details on translating .htaccess content to IIS web.config: http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig

    OR create Rewrite Rules in IIS UI: http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module