Rewriterule for directing part of a servers traffic

I need to redirect a part of a website to a new webserver
where (oldsite.com becomes newsite.com) and this string (Store_Code=abcd) is in the uri.

if Store_Code=abcd
http://www.oldsite.com/Merchant2/merchant.mvc?Store_Code=abcd&otherstuf=blablabla
becomes
http://www.newsite.com/Merchant2/merchant.mvc?Store_Code=abcd&otherstuf=blablabla

Nothing I've tried works
LVL 1
kiqkinasAsked:
Who is Participating?
 
ahoffmannConnect With a Mentor Commented:
RewriteCond %{SERVER_NAME} ^www.oldsite.com$
RewriteCond %{REQUEST_URI} .*\?Store_Code=abcd
RewriteRule .* http://www.newsite.com/Merchant2/merchant.mvc?Store_Code=abcd&otherstuf=blablabla

# Note: that's the lazy aproach according the lazy description ;-)
0
 
kiqkinasAuthor Commented:
Well not quite.

I had originally tried:
RewriteCond %{REQUEST_URI} !-s
RewriteRule ^([^/]+)poconomts.com/([^/]+)Store_Code=Bdix([^/]+).*$ $1bendixens2.com/$2Store_Code=Bdix$3 [PT,NE]

My difficulty is that what comes before and after Store_Code=Bdix can change.
you sugestion of RewriteCond %{REQUEST_URI} .*\?Store_Code=abcd may point me in a better direction.

0
 
kiqkinasAuthor Commented:
Still cant get this to work

RewriteEngine on

RewriteCond %{SERVER_NAME} ^www.oldsite.com$
RewriteCond %{REQUEST_URI} .*=Bdix
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=permanent,L]

The problem seems to be in RewriteCond %{REQUEST_URI} .*=Bdix.
If I eliminate the line the entire site gets re-directed as expected changing just the domainname in the uri.
I've tried dozens of variation on the condition to no avail. Please help.
.*=Bdix
.*=Bdix. *
^.*=Bdix.*$
^(.*)=Bdix(.*)$

0
 
kiqkinasAuthor Commented:
Found it:
RewriteEngine on

RewriteCond %{SERVER_NAME} ^www.oldsite.com$
RewriteCond %{QUERY_STRING} .*=bdix.* [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=permanent,L]
0
 
ahoffmannCommented:
.*bdix.* is required if you have more parameters in the URI
0
All Courses

From novice to tech pro — start learning today.