How do we escape an '&' on rewritecond

Oh, the strange things mod_rewrite does!

How do we escape an '&' on rewritecond

Postby vinay.chilakamarri » Tue Aug 05, 2008 4:57 pm

Hi,

I have this rewrite cond:

RewriteCond %{QUERY_STRING} ^nm=([^/]+)&ip=(.*\..*\..*\..*)&sl=(\d+)$

I pass the parameters that i gather in those regular expressions to a script. Instead of doing this, I wanted to pass in the entire string into the script and then split it on '&' in the script. I tried this:

RewriteCond %{QUERY_STRING} ^(.*)$

But I observed that the script gets only the string that is present before the '&'. For example, if i pass: http://localhost:123/query?par=12&p=13,

My script gets only 'par=12'. How do I tell modrewrite to ignore '&'
vinay.chilakamarri
 
Posts: 10
Joined: Fri Jun 20, 2008 4:42 pm

Postby vinay.chilakamarri » Wed Aug 06, 2008 10:07 am

I figured this out. The reason for this is not the mod_rewrite but the module that I was using for parsing the parameters in my perl script.

Off topic but for the ones using perl to figure out parameter string passed in by mod_rewrite function, you could use this:

my $ur = $ENV{"QUERY_STRING"};


this will pass in anything after the '?' of the GET request URL.
vinay.chilakamarri
 
Posts: 10
Joined: Fri Jun 20, 2008 4:42 pm


Return to Idiosyncrasies

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron