Thursday, 22 August 2013

Trying to fix double-encoding in htaccess

Trying to fix double-encoding in htaccess

Using .htaccess, is it possible to convert urls to lowercase, but allow
uppercase encoding?
Current file:
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].* [OR]
RewriteCond %{QUERY_STRING} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}}?${lc:%{QUERY_STRING}} [L,NE,R=301]
RewriteRule ^client/(.*) client.php?q=type:$1 [QSA]
Browser: domain.com/client/city?mf[]=liverpool (correct)
Googlebot: domain.com/client/city?mf%5d%5b=liverpool (301, incorrect)
If I remove [NE], the resulting url is double encoded:
Browser: domain.com/client/city?mf%255b%255d=liverpool (200, but incorrect
results)
Googlebot: domain.com/client/city?mf%255b%255d=liverpool (200, but
incorrect results)
Desired output:
Browser: domain.com/client/city?mf[]=liverpool (correct)
Googlebot: domain.com/client/city?mf%5D%5B=liverpool (200, correct)
I'm forcing lowercase using RewriteMap as the previous site was mixed
case, with far too many combinations to manage. Have spent the whole day
reviewing threads, but can't seem to isolate the problem.. or perhaps I'm
looking at this the wrong way.
Thank you.

No comments:

Post a Comment