【发布时间】:2017-10-09 00:24:41
【问题描述】:
我对将 index.html 的任何字母大小写组合的 URL 重定向到 index.html 的所有小写字母感兴趣。
即:
/foo/bar/INDEX.html
to
/foo/bar/index.html
or
/hello/world/funk/indeX.HTML
to
/hello/word/fund/index.html
我尝试了几个正则表达式,但没有运气。仅当index.html 中有任何大写字母时,我才对重定向感兴趣
/hello/there/index.html
不应重定向到任何地方。
我可以访问 httpd.conf,因此我使用的是RewriteMap lc int:tolower
【问题讨论】:
-
可能最简单/最直接的正则表达式是
^(.*)[iI][nN][dD][eE][xX]\.[hH][tT][mM][lL]$。但是,它不满足仅重写并且仅在至少有 1 个大写字母时才重写的要求。它也会匹配小写的index.html。但我不明白为什么会有问题。
标签: regex apache http url url-rewriting