views:

339

answers:

1

In my .htaccess file I have defined following rule,

RewriteRule t/([^.]+)/$ /videos/tag.php?tag=$1 [QSA]

The above rule works fine if I am browsing http://example.com/videos/t/world+news/ or http://example.com/videos/t/events/

but when I am browsing http://example.com/videos/t/business+%26+world/ (here original tag is: business & world) then in my query string tag variable I am getting only business. '& world' is not coming when I am fetching variable data through $_GET['tag']

Can anyone please tell where is the problem in the above rule??

+2  A: 

Try the B flag to escape the backreference:

RewriteRule ^t/([^.]+)/$ /videos/tag.php?tag=$1 [B,QSA]


Edit   How about this:

RewriteRule ^([^&]*)&(.*)/$ $1\%26$2 [N,NE]
RewriteRule ^t/([^.]+)/$ /videos/tag.php?tag=$1 [QSA]

The first rule is to replace the & with %26.

Gumbo
Its not working. When I am adding [B,QSA] then it gives me "500 Internal Server Error" without that B only [QSA] is working fine. ??
Prashant
I think that flag was introduced with Apache 2.
Gumbo
Ok,but I am running my website with this configuration `Apache/2.2.3 (CentOS)` and other thing is your new code is not working? don't know hwy but its displaying only a blank page after adding that %26 rule.
Prashant
Prashant
any replies ???
Prashant
Gumbo