RewriteCond/RewriteRule 具有不区分大小写和尾部斜杠功能吗?
我遇到以下两行问题:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+[^/])$ /$1.html [L]
目标:重定向“domain.tld/test/”(仅当 test.html 存在时),以便输出“domain.tld/test.html”的内容。
- 如何使其不区分大小写:“domain.tld/Test”-> domain.tld/test.html **
- 如何让它接受尾部斜杠:“domain.tld/test/”也应该有效,
谢谢!
** 我无法让 RewriteMap lowercase int:tolower 工作,感谢任何帮助。
I got problems with the following two lines:
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+[^/])$ /$1.html [L]
Goal: Redirecting "domain.tld/test/" (only if test.html exists) so that it outputs the contents of "domain.tld/test.html".
- How to make this case-insensitive: "domain.tld/Test" -> domain.tld/test.html **
- How to make it accept a trailing slash: "domain.tld/test/" should work, too
Thanks!
** I couldn't get RewriteMap lowercase int:tolower to work, any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 [NC] 进行不区分大小写的检查。
请参阅此处了解尾部斜杠问题:模式重写;网址末尾有/没有尾部斜杠吗?
Use [NC] for case insensitive checking.
See here for the trailing slash issue: Mode Rewrite; with/without trailing slash on end of url?
试试这个:
此外
RewriteMap
只能在服务器配置或虚拟主机上下文中使用,但不能在 .htaccess 文件中使用。所以你需要在那里定义重写映射。Try this:
Furthermore
RewriteMap
can only be used in the server configuration or virtual host context but not in a .htaccess file. So you need to define the rewrite map there.