Forum Moderators: phranque

Message Too Old, No Replies

Rewrite Amazon aStore URI - I'm almost there, but -

I need to solve one mod_rewrite issue.

         

Winnetou

1:17 am on Sep 28, 2008 (gmt 0)

10+ Year Member



Hi community,

I'm rewriting URLs to integrate an Amazon aStore via a web proxy into my site (to get greater flexibility than with iframes).

Everything's fine minus the last bit: When you click on an "update cart" link it comes back with the default store page, not the updated cart.

I've traced it down to a URL rewrite issue. Clicking on "update cart" triggers a link of the form

[local.mysite.com...]

which currently only runs on my local server (hence the 'local').

My .htaccess contains the following to rewrite any links with 'ast' (Amazon Store):

RewriteRule ^ast/(.*)$ /proxy/proxy-index.php?q=$1 [L,QSA]

This sends any link with 'ast' in it to the proxy script. QSA should preserve any url parameters.

However, when I log the rewrite process for that particular link I get this entry:

split uri=/proxy/proxy-index.php?q=my-store-id/cart/modify/another-id-here -> uri=/proxy/proxy-index.php, args=q=my-store-id/cart/modify/another-id-here&Item.1.Quantity=1&Item.1.CartItemId=U39TZ#*$!MYPT9T&pngImage.x=23&pngImage.y=7&pngImage=Go

Note the '&' which follows 'another-id-here' which, in the original link posted above, has been a '?'.

Hence the link parameters are not recognised and Amazon sends back the default store page.

My question is where does the '&' come from?

My setup works for links like:

[local.mysite.com...]

Thanks for your help!

g1smd

9:24 am on Sep 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The & comes from the QSA adding on the original query string, appending it, to the one already there (the bit right after args= that is).

Winnetou

10:13 am on Sep 28, 2008 (gmt 0)

10+ Year Member



Thanks for the reply.

I'm one step further. It actually wasn't the mod_rewrite which caused the problem, it was a 302 "Moved temporarily" response that the proxy script could not handle.

g1smd

10:19 am on Sep 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This would be a good time to use Live HTTP Headers for Mozilla Firefox (if you haven't already) and check the responses from start to finish.

A 302 redirect (rather than a 301 redirect or a rewrite) can be problematical, especially for search engines, in many situations.

twinky

11:09 pm on Jan 23, 2009 (gmt 0)

10+ Year Member



It appears the problem is related to cookie processing. mod_rewrite can't do it for you. I think it is better to use specialized aStore proxy like StoreBrander.com in your case. It is free and has reach features set.