bonez
bonez

Reputation: 695

mod_rewrite with %26

I'm trying to pass in as a parameter a category name like this

"Lights+&+Lamps"

with this rewrite rule

RewriteCond %{HTTP_HOST}        example.com$
RewriteRule ^/category/([^/]+)$   /showproduct.pl?category=$1 [PT]

I understand & is a paramater separator, but even when I pass in :

"Lights+%26+Lamps"

My output is "Lights"

So mod rewrite is eating everything at %26

I've tried different flags like [NE] and QSA with no luck.

Any ideas?

Upvotes: 2

Views: 388

Answers (2)

jszoja
jszoja

Reputation: 349

I had similar problem where the '&'(ampersand) was incorrectly rewritten by the mod_rewrite. The B flag solved it:

B (escape backreferences) The [B] flag instructs RewriteRule to escape non-alphanumeric characters before applying the transformation.

It allowed me to serve the files containing '&' within their name, eg here What you need is this

RewriteCond %{HTTP_HOST}        example.com$
RewriteRule ^/category/([^/]+)$   /showproduct.pl?category=$1 [B, PT]

Upvotes: 1

thejh
thejh

Reputation: 45568

Could you rewrite % to %25 with another rule before that?

Upvotes: 0

Related Questions