user1852010
user1852010

Reputation: 11

Apache Rewrite Rule With % characters

I have a url that needs to be rewritten.

http://aplus-carpetcleaning.com/home.php%3Fcity%3DGainesville%2520VA

I have tried this:

^home\.php%3Fcity%3DGainesville%2520VA$ "http://aplus-carpetcleaning.com/home.php?city=Gainevilles%20VA"

This is not being recognized. Tried various alternates but no dice.

Notes:

Upvotes: 1

Views: 1665

Answers (2)

user1852010
user1852010

Reputation: 11

Fixed it with:

RewriteRule ^home\.php(.*)city(.*)Gainesville(.*)VA$ "http:\/\/aplus\-carpetcleaning\.com\/home\.php?city=Gainesville VA" [R=301,L]

Upvotes: 0

arkascha
arkascha

Reputation: 42925

The rewriting module applies your regex patterns to decoded urls, not the urlencoded string you see inside the browsers url field.

So create your regex pattern using unescaped characters instead. Something like:

^home.php\?city=Gainesville&20VA$

Upvotes: 1

Related Questions