2

i am using htaccess rule for url rewriting

RewriteCond %{THE_REQUEST} /buy-car\.php\?make=([^\s&]+)&model=([^\s&]+)&year=([^\s&]+)\s [NC]
RewriteRule ^ buy-car/%1/%2/%3? [R=302,L]

RewriteRule ^buy-car/([\w-]+)/([\w-]+)/([\w-]+)/?$ buy-car.php?make=$1&model=$2&year=$3 [L,QSA,NC]

this makes url like

 www.example.com/buy-car/audi/x5/2015

but sometime i may have url like this

www.example.com/buy-car/audi/x5/2000%3B2015

%3B represents ;  

now how to change my htaccess rules to work fine.

thanks

ahmad ali
  • 1,155
  • 1
  • 9
  • 17
  • Did you try using '%25' instead of liteal '%'? Also, there is plenty of related information in http://stackoverflow.com/questions/7673439/error-with-and-htaccess – Wiktor Stribiżew Mar 07 '15 at 10:22

2 Answers2

0

Add a backslash in front of %. Try using: ([\%\w-]+) in your regexp.

engine9pw
  • 364
  • 1
  • 5
0

Allow ; in your character class. Have 2nd rule as:

RewriteRule ^buy-car/([\w;-]+)/([\w;-]+)/([\w;-]+)/?$ buy-car.php?make=$1&model=$2&year=$3 [L,QSA,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643