How do I write a rewrite-rule that redirects visitors to the domain www.mydomain.com/
to www.mydomain.com/index.html
?
views:
254answers:
2
+4
A:
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]
BalusC
2009-12-16 00:19:39
+3
A:
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. :)
Evgeny
2009-12-16 00:20:28
Seeing the context of the question (apache already does that by default) I rather think he just want to get rid of it :)
BalusC
2009-12-16 00:22:31
I wanted it for this reason: http://serverfault.com/questions/94706/how-to-password-protect-the-domain-with-htaccess
Jenko
2009-12-16 13:28:53