使用 htaccess 将 url 转换为小写,查询字符串除外 [英] Convert url to lower case using htaccess except query string
本文介绍了使用 htaccess 将 url 转换为小写,查询字符串除外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力解决 htaccess 问题.
Am struggling with a htaccess problem.
我需要将所有 URL 从大写转换为小写.但是单独的查询字符串应该是一样的.
I need to convert all the URLs from uppercase to lowercase. But the query string alone should be the same.
例如
www.tESTUrl.com/sOMePath/?q=SomeStringHere
应该转换为,
www.testurl.com/somepath/?q=SomeStringHere
请帮忙解决这个问题.提前致谢.
Please help to fix this. Thanks in advance.
推荐答案
首先你必须把这个添加到你的 httpd.conf:
First You have to add this to your httpd.conf:
RewriteMap lc int:tolower
然后将以下代码粘贴到您的 .htaccess
Then paste the below code into your .htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]
这段代码重定向了来自
www.tESTUrl.com/sOMePath/?q=SomeStringHere
到www.testurl.com/somepath/?q=SomeStringHere
这篇关于使用 htaccess 将 url 转换为小写,查询字符串除外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文