【发布时间】:2011-05-24 17:18:42
【问题描述】:
我想将所有以 index.html 结尾的 URL 的请求定向到 /。我在服务器上有一个域。
例子:
- 如果有人想要“www.thissite.com/index.html--它被定向到 www.thissite.com/。 和
- 如果有人想要“www.thissite.com/anyword/index.html”——它会被定向到 www.thissite.com/。 和
- 如果有人想要“www.thissite.com/folderdoesntexistonthissite/index.html”--它会被定向到 www.thissite.com/。
启用此功能的 .htaccess 代码是什么? (重写条件和重写规则)
这并不能很好地完成工作:
RewriteCond %{THE_REQUEST} index\.html [NC]
RewriteRule index\.html$ http://www.thissite.com/$1 [R=301.L]
【问题讨论】:
标签: apache .htaccess mod-rewrite url-rewriting