apacheunix.htaccesshttp-redirectwebserver

Htaccess rule to redirect domain to index.html


How do I write a rewrite-rule that redirects visitors to the domain www.mydomain.com/ to www.mydomain.com/index.html?


Solution

  • So you want to redirect nothing (^$) to index.html? That would then look like

    RewriteRule ^$ index.html [L]
    

    If you want to avoid both the / and /index.html being indexed by search bots, then add R=301 to make it a permanent redirect rather than a temporary redirect (302, which is the default). This would let the bots only index the /index.html.

    RewriteRule ^$ index.html [R=301,L]