• GoDaddy Community
  • Websites + Marketing | Website Builders
  • Websites + Marketing | Website Builders

    cancel
    Showing results for 
    Show  only  | Search instead for 
    Did you mean: 
    Go to solution

    Load index.html when URL points to subfolder

    I'd like a URL that points to sub-folder to load index.html from that folder:

    User types:

    www.example.com/subpage/

    Browser loads this but the user does not see the "index.html" in the URL:

    www.example.com/subpage/index.html

    I tried adding .htaccess file to this sub-folder with this but it did not work:

    DirectoryIndex index.html

    Please help! Thanks!

    4 REPLIES 4

    Re: Load index.html when URL points to subfolder

    So far I have found that this works:

    RedirectMatch ^/subfolder/?$ /subfolder/index.html

    The problem is that the user is redirected and the "index.html" is visible in the address bar which is not ideal.

    Any idea why DirectoryIndex wouldn't work?

    Thank you

    Super User III Super User III
    Super User III

    Re: Load index.html when URL points to subfolder

    What you've described should be the default behavior.  Do you have other scripting that could be interfering with this?

    Re: Load index.html when URL points to subfolder

    I have some rewrite rules in .htaccess but that should not cause any interference, should it?

    Solution

    Re: Load index.html when URL points to subfolder

    Turns out I had a php rewrite rule in .htaccess that looked like this that was interfering with the default DorectoryIndex behavior. 

     

    RewriteCond %{REQUEST_URI} \.html$ 
    RewriteRule . /rewrite.php [L]

    Removing this fixed the problem! Yay!