Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Htaccess小写URL子字符串(如果在不同的情况下找到)_.htaccess - Fatal编程技术网

.htaccess Htaccess小写URL子字符串(如果在不同的情况下找到)

.htaccess Htaccess小写URL子字符串(如果在不同的情况下找到),.htaccess,.htaccess,如果.htaccess中的URL字符串不是小写的,我想将其部分小写 例如 http://www.example.com/This-Needs-to-Change/cars.aspx 到 http://www.example.com/this-needs-to-change/cars.aspx 只有在找到该字符串的大写字母(需要更改)时,我的重写条件才应该更改什么?在您的httpd配置文件或vhost配置文件中定义此RewriteMap: RewriteMap lc int:tolower 然后

如果.htaccess中的URL字符串不是小写的,我想将其部分小写

例如

http://www.example.com/This-Needs-to-Change/cars.aspx

http://www.example.com/this-needs-to-change/cars.aspx


只有在找到该字符串的大写字母(需要更改)时,我的重写条件才应该更改什么?

在您的httpd配置文件或vhost配置文件中定义此
RewriteMap

RewriteMap lc int:tolower
然后在您的站点root.htaccess中,在
/
之前将此规则的第一部分小写:

RewriteEngine On

RewriteCond $1 [A-Z]
RewriteRule ^(this-needs-to-change)(/.*)?$ /${lc:$1}$2 [R=302,NC,NE,L]

您好@anubhava是的,我有,但是如果可能的话,我更喜欢在.htaccess中进行,以避免apache重新启动,并在以后根据需要进行修改。好的,我可以这样做,然后cars.aspx可以是任何动态的。这会影响URL中的其他大写字符串吗?更清楚地说,我只想修改一个字符串(这需要更改),所有其他字符串都不会受到影响。