I'm trying to rewrite a url that contains the & symbol. I've tried with & and %26, but both get stripped out by apache.
For example, if the url is:
healthyliving/fruit/apples_&_pears
and the rewriterule is:
RewriteRule ^healthyliving/fruit/([^/.]+)$ food.php?subpage=healthyliving&item=$1 [QSA,L]
The querystring would show "apples_&pears", but _GET['item']
would show "apples".
From what I've read, most solutions use the B flag to escape backreferences. This flag was introduced in 2.2.7. Unfortunately we are running an earlier version and we cannot updgrade right now for various reasons.
Is there a way to achieve what I need without the use of the B flag?
I'm not entirely sure what you're trying to accomplish with the $_GET, but you could try this
RewriteRule ^healthyliving/fruit/(.*)_&_(.*) food.php?subpage=healthyliving&item[]=$1&item[]=$2 [QSA,L]
Which should give you:
Array ( [subpage] => healthyliving [item] => Array ( [0] => apples [1] => pears ) )