将域重定向到 index.html 的 Htaccess 规则 [英] Htaccess rule to redirect domain to index.html

查看:26
本文介绍了将域重定向到 index.html 的 Htaccess 规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写将访问者重定向到域 www.mydomain.com/www.mydomain.com/index.html 的重写规则?

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

推荐答案

所以你想将 nothing (^$) 重定向到 index.html?然后看起来像

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

RewriteRule ^$ index.html [L]

如果您想避免 //index.html 被搜索机器人索引,请添加 R=301 使其成为永久 重定向 而不是 临时 重定向(302,这是默认值).这会让机器人只索引 /index.html.

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]

这篇关于将域重定向到 index.html 的 Htaccess 规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆