Link to home
Start Free TrialLog in
Avatar of MAVERICK
MAVERICKFlag for United States of America

asked on

Apache mod_rewrite question

Hi Everyone,

I'm trying to make a rule to return more than one variable for the rewrite.
http://www.devserver.local/product.AB1234.htm?Affiliate=maverick

This one works except nothing gets returned in $2

RewriteCond %{QUERY_STRING} Affiliate=(.*)
RewriteRule ^product\.(.*).htm http://miva.devserver.local/Merchant2/merchant.mvc?Screen=PROD&Store_Code=EFY&Product_Code=$1&Affiliate=$2 [R,L]

This doesn't work
RewriteCond %{QUERY_STRING} Affiliate=(.*)
RewriteRule ^product\.(.*).htm(\?.*) http://miva.devserver.local/Merchant2/merchant.mvc?Screen=PROD&Store_Code=EFY&Product_Code=$1&Affiliate=$2 [R,L]

Can someone explain what I've done wrong.

Regards
Maverick
Avatar of Mercantilum
Mercantilum
Flag of Japan image

The RewriteCond substitution is with %1  (and the . of .htm would prefer a \, while it is not mandatory)

RewriteCond %{QUERY_STRING} Affiliate=(.*)
RewriteRule ^product\.(.*)\.htm http://miva.devserver.local/Merchant2/merchant.mvc?Screen=PROD&Store_Code=EFY&Product_Code=$1&Affiliate=%1 [R,L]


What are you trying to do with the 2nd rule and \? ?

RewriteCond %{QUERY_STRING} Affiliate=(.*)
RewriteRule ^product\.(.*).htm(\?.*) http://miva.devserver.local/Merchant2/merchant.mvc?Screen=PROD&Store_Code=EFY&Product_Code=$1&Affiliate=%1 [R,L]
Avatar of MAVERICK

ASKER

Hello

Grab the affiliate code(Affiliate=Maverick) so it can be passed to the shopping cart

Cheers!
--John
ASKER CERTIFIED SOLUTION
Avatar of Mercantilum
Mercantilum
Flag of Japan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Mercantilum,

The both rules were supposed to do the same thing, i was just documenting the things I tried.

The rule you provided worked flawlessly.

Thanks again,
Maverick