arsen_adzhiametov
arsen_adzhiametov

Reputation: 696

mod_rewrite RewriteRule anomaly

I'm preparing rewrite rules for my site. And I'm faced problem when target URL contains characters like "%3A". Apache mod_rewrite just removes "%3" when rewrites url.

For example I need rewrite url

/primed-white-mdf-skirting+architrave/  

to

/Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=%3AtopSellers%3AColour%3AWhite&text=#

I have generated rule for this. Here it is:

RewriteRule ^primed-white-mdf-skirting\+architrave/ /Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=%3AtopSellers%3AColour%3AWhite&text=# [R=301,L,NE]

So rewrite pass to:

 /Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=AtopSellersAColourAWhite&text=%23

Why this happens? Please help

Upvotes: 1

Views: 35

Answers (1)

anubhava
anubhava

Reputation: 785481

You need to escape the % otherwise %3 is considered a back-reference of captured group from RewriteCond:

RewriteRule ^primed-white-mdf-skirting\+architrave/ /Products/Decorating+Interiors/Mouldings/Skirting/c/1000589?q=\%3AtopSellers\%3AColour\%3AWhite&text=# [R=301,L,NE,QSA,NC]

Upvotes: 1

Related Questions