php - 非常基本的重写规则问题

标签 php html apache .htaccess mod-rewrite

我有这个网址:

 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/

相关文章:

python - Flask/wsgi - 写入日志文件或接触随机文件时权限被拒绝

php - 如何创建 jquery 函数来防止向数据库重复输入

php - 使用 jQuery 的方法 .ajax() 在 PHP 中发送表单

javascript - 如何在javascript中将数据加载到特定的输入值?

html - 在 Chrome 中使用 `z-index` 的固定父元素下的元素

apache - 针对浏览器缓存的特定文件/文件夹

regex - 如何解析 Apache Catalina.log

php - 对 SSL 的 Soap 客户端调用

php - 从 Tinyint 中检索并转换为 html 中的文本

javascript - IE 哈希返回按钮的问题