重写URL以全部小写 [英] rewriting URL to all lowercase
本文介绍了重写URL以全部小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的重写规则在我的.htaccess
的RewriteCond%{} REQUEST_FILENAME -f .PHP
重写规则^([^ /。] +)/?(。*)$ /$1.php/$2 [QSA,L]
重写规则^ 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
解决方案
定义类型 INT
(内部)引用的RewriteMap指令TOLOWER
函数,并调用它,你想做的lowercasing:
RewriteMap指令LC INT:TOLOWER
的RewriteCond%{} REQUEST_FILENAME -f .PHP
重写规则^([^ /。] +)/?(。*)$ /${lc:$1}.php/${lc:$2} [QSA,L]
重写规则^ API /([AZ] +)/([AZ] +)/api/${lc:$1}_${lc:$2}.php}
I have this rewrite rule in my .htaccess
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/.]+)/?(.*)$ /$1.php/$2 [QSA,L]
RewriteRule ^api/([a-z]+)/([a-z]+) /api/$1_$2.php
How can I modify this to change everything in my URL to lowercase?
i.e. This:
www.mysite.com/ThisURL/SHOULD/be_all_lowercse
Should be
www.mysite.com/thisurl/should/be_all_lowercase
解决方案
Define a RewriteMap of type int
(internal) referencing the tolower
function, and call it where you want to do the lowercasing:
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}
这篇关于重写URL以全部小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文