You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "HIRODE,KARTHEEK (HP-Boise,ex1)" <ka...@hp.com> on 2003/11/21 03:09:30 UTC

[users@httpd] Tricky rewrite question

Hi All,

I need to redirect all the calls coming to our server with
"/apps/Control?h_cc=oldValue&cc=oldValue" to
"/apps/Control?h_cc=newValue&cc=newValue". 
I have these h_cc and cc parameters which can occur in any order in the url.
I have to replace the 'oldValue' with 'newValue'.
I have the following rule but it changes only parameter which ever occurs
the last, the other parameter still retains the old value

RewriteCond %{QUERY_STRING} ^(.*)(&*)cc=oldValue(&|$)(.*)$
RewriteRule ^/apps/(.*) /apps/$1?%1%2cc=newValue%3%4 [R,L]

How can I make both the values change at the same time? Can any one suggest
me.

Thanks Much




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Tricky rewrite question

Posted by Joshua Slive <jo...@slive.ca>.
On Thu, 20 Nov 2003, HIRODE,KARTHEEK (HP-Boise,ex1) wrote:

> Hi All,
>
> I need to redirect all the calls coming to our server with
> "/apps/Control?h_cc=oldValue&cc=oldValue" to
> "/apps/Control?h_cc=newValue&cc=newValue".
> I have these h_cc and cc parameters which can occur in any order in the url.
> I have to replace the 'oldValue' with 'newValue'.
> I have the following rule but it changes only parameter which ever occurs
> the last, the other parameter still retains the old value
>
> RewriteCond %{QUERY_STRING} ^(.*)(&*)cc=oldValue(&|$)(.*)$
> RewriteRule ^/apps/(.*) /apps/$1?%1%2cc=newValue%3%4 [R,L]
>
> How can I make both the values change at the same time? Can any one suggest
> me.

Something like this may work:

RewriteCond %{QUERY_STRING} ^(.*)cc=OldValue(&?.*)$
RewriteRule ^/apps/(.*) /apps/$1?%1%2 [C]
RewriteCond %{QUERY_STRING} ^(.*)h_cc=OldValue(&?.*)$
RewriteRule ^/apps/(.*) /apps/$1?%1%2&cc=newValue&h_cc=newValue [L,R]

It's not perfect, but it may give you an idea.  Alternatively, just make
two separate sets of rewriterule's, one for when cc is first, and one for
when h_cc is first.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org