如何执行从 index.htm 到 root 的简单 301 重定向?
我读过各种有关重定向的参考网站,说实话我了解甚少。
目前,我的 .htaccess 中有标准的 WordPress mod_rewrite 重定向规则:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
我的相当多的引荐来源网址都转到旧 URL http://www.example.com/index.htm
,这会给他们带来错误,我希望它们能够无缝重定向到 http://www.example.com/
。我相信 301 重定向是最好的方法。
我需要做什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这会将所有出现的index.html 或index.htm 递归地转换为目录。
This will translate all occurrences of index.html or index.htm to just the directory, recursively.
我不是 100% 确定,但我想应该是
RewriteRule ^index.htm$ / [R=301]
或类似的东西I'm not 100% sure but i guess that should be
RewriteRule ^index.htm$ / [R=301]
or something like this创建一个index.html,包含以下代码:
其中“秒”是重定向之前的延迟持续时间(以秒为单位)。设置“0”以进行即时重定向。
“the-other-url”是 http://www.example.com/index.php
Create an index.html, containing the code:
Where "seconds" is the duration of the delay (in seconds) before the redirection. Set a "0" for instant redirect.
"the-other-url" is http://www.example.com/index.php