Forum Moderators: phranque
and want to drop the sid in each case (while retaining the possibility of other query parameters as in the first case).
I've actually got it working with ereg_replace:
ereg_replace("((\&joe)=([a-zA-Z0-9]))",'',"www.a.com?b=6&joe=7&c=9")
but I just can't seem to get it to work in .htaccess. I'm checking for my IP address only so that [hopefully] my website will stay up for everyone else. The line will be replaced by conditions looking for bots in the agent.
RewriteCond %{REMOTE_ADDR} ^my.ip.address$
RewriteCond %{QUERY_STRING} ^(^&)(joe)=([a-zA-Z0-9])(.*)$
RewriteRule ^.*$? [C]
RewriteRule ^.*$?%1%4 [R=301]
At this point I'm not even bothering with the second case, I'm just trying to get the first one to work. I've just started using the second RewriteCond on the last 17 iterations because if I'm reading the docs right the query string doesn't get presented in the RewriteRule directive. Before that I was trying to do it with one Cond (the ip exclusion) and one Rule (variations of the last one up there with $1 etc. instead of %1 etc). I'm not seeing any change in the url in my browser.
I've been over the stuff in the library, and I've been over and over the apache docs. While the apache docs finally stopped giving me a raging headache, this stuff just doesn't seem to be penetrating my skull...
I'm pretty sure I can just take care of the whole thing in my php scripts, but it's irking the heck out of me that I can't get this to work.
[edited by: jdMorgan at 2:30 pm (utc) on Feb. 19, 2007]
[edit reason] Disabled smilies in code. [/edit]
RewriteCond %{REMOTE_ADDR} ^my\.ip\.add\.ress$
RewriteCond %{QUERY_STRING} ^(([^&]*&)*)sid=[^&]*(&([^&]*&)*)?$
RewriteRule (.*) http://example.com/$1?%1%3 [R=301,L]
[^&]*& == "any number of characters not equal to an ampersand, followed by an ampersand."
([^&]*&)* == "As many of the above sequence as you like."
(([^&]*&)*) == And pack them all into %1 for easy back-reference.
Jim