我有这个网址:
http://www.mydomain.com/index.html
并且想要一条规则将上面的重写成这样:
http://www.mydomain.com
换句话说,删除 index.html 部分代码...
可能是这样的:
RewriteRule ^$ index.html [NC]
谢谢
更新:
当您在浏览器中输入 www.domain.com 时,会打开 offcourse index.html。 但是当你点击我网站菜单上的“主页”时,会显示整个完整的 url,我想避免这种情况。因此,当点击“home”时,会显示 www.domain.com/index.html ......但是当在地址栏中输入 www.domain.com 时,只会显示 www.domain.com/index.html,但无论如何都会出现 index.html。
所以是的,我需要这个:
www.domain.com/
不是这个:
www.domain.com/index.html
谢谢
最佳答案
将对/index.html 的请求重定向到/
RewriteRule ^index.html$ http://www.mydomain.com/ [R=301,L]
关于php - 非常基本的重写规则问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3590978/