开发者

HTACCESS - regex / contains a capital letter?

开发者 https://www.devze.com 2023-02-07 07:07 出处:网络
I\'m trying to redirect all addresses which contain at least one capital character. 开发者_StackOverflow社区i.e:

I'm trying to redirect all addresses which contain at least one capital character.

开发者_StackOverflow社区

i.e:

dont rewrite - cities/nashville , but rewrite - cities/Nashville.


You can use the NC flag to ignore the case for the pattern matching:

RewriteRule ^jewelry-stores/nashville$ /jewelry/cities/nashville [L,R=301,NE]

Otherwise, if you want to test for at least one capital letter, use [A-Z]:

RewriteRule ^jewelry-stores/([^A-Z]*[A-Z].*) /jewelry/cities/${tolower:$1} [L,R=301]

Additionally the internal mapping function tolower is used to turn the matched string into lowercase. (Note that RewriteMap requires access to the server or virtual host configuration.)


something like

RewriteRule ^citites/.*[A-Z].*$  /whatever [L,R=301]

should work as expected

0

精彩评论

暂无评论...
验证码 换一张
取 消