Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 962
Robin Rodricks Avatar asked Dec 16 '09 00:12

Robin Rodricks


2 Answers

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]
like image 57
BalusC Avatar answered Sep 19 '22 20:09

BalusC


What BalusC said - but consider whether you really want to redirect them. Wouldn't it be better to just serve index.html when the browser requests /, like most servers do? It's an extra round-trip to the server for no gain and just makes the URL longer. It's so 1990s. :)

like image 39
EMP Avatar answered Sep 21 '22 20:09

EMP