我的.htaccess
中有这个重写规则RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)/?(.*)$ /$1.php/$2 [QSA,L]
RewriteRule ^api/([a-z]+)/([a-z]+) /api/$1_$2.php
如何修改此项以将网址中的所有内容更改为小写?
即。这样:
www.mysite.com/ThisURL/SHOULD/be_all_lowercse
应该是
www.mysite.com/thisurl/should/be_all_lowercase
答案 0 :(得分:2)
此article描述了如何执行此操作:
RewriteEngine On
RewriteMap lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
答案 1 :(得分:1)
定义一个引用int
函数的tolower
(内部)类型的RewriteMap,并将其调用到您想要进行小写的位置:
RewriteMap lc int:tolower
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)/?(.*)$ /${lc:$1}.php/${lc:$2} [QSA,L]
RewriteRule ^api/([a-z]+)/([a-z]+) /api/${lc:$1}_${lc:$2}.php}