richard
richard

Reputation: 1546

Issue of upper case & lower case in rewriteCond %{QUERY_STRING} mod_rewrite

I have this code in my htaccess to redirect people who try to access any url that contains query string "username=richard".

RewriteCond %{QUERY_STRING} (^|&)username=richard(&|$)
RewriteRule .* /? [R,L]

The above code works great if someone enter:

example.com/folder.php?username=richard

But i found that it's not working if someone enter upper case in the string value:

example.com/folder.php?username=Richard

or

example.com/folder.php?username=riChard

and etc..

So how to solve the upper/lower cases problem?

Upvotes: 0

Views: 742

Answers (1)

Amine Hajyoussef
Amine Hajyoussef

Reputation: 4440

add No case flag:

RewriteCond %{QUERY_STRING} (^|&)username=richard(&|$) [NC]
RewriteRule .* /? [R,L]

Upvotes: 2

Related Questions