Forum Moderators: phranque
Scenario:
* site has migrated from one shopping cart to another
* query string for individual products has changed, and now jumps out to another server
* product IDs are not the same from old cart to new cart
What I need to do:
Point old product URL
[mysite.com...]
To new product URL (on different server)
[newhost.com...]
Where do I start? I know I can't do a straight 301 Redirect because of the query string. From what I've read I need to use [QSA]? But can't find a working example. The book I'm reading talks about it (The Definitive Guide to Apache mod_rewrite), but I don't see a good example.
Cheers, Jamie
For small applications, a simple series of RewriteConds and RewriteRules can be used. For larger applications, your best bet is either a text lookup table, or a database query using RewriteMaps (in addition to one or a few RewriteConds and RewriteRules. The former solution is relatively simple, while the latter, though not dauinting, is certainly not trivial, and will require a small PERL script to do the database lookup and return the new URL and parameters.
Jim
Thank you for your response.
I have a total of 8 products that need to be updated.
With some additional digging I've found a similar post:
[webmasterworld.com...]
The example in the post above has this:
RewriteEngine on
RewriteCond %{query_string} ^p=78598870&more=1
RewriteRule /* http://example.com/archives/000124.php [R,L]
* {query_string}: Is this the start of the old URL with the string?
* What if I'm two directory levels deep to I append the static part of the URL before {query_string}
Again, thank you for your help.
Cheers, Jamie
[edited by: jdMorgan at 4:27 pm (utc) on Oct. 17, 2007]
[edit reason] example.com [/edit]
Use the RewriteRule pattern to test the URL-path itself -- Everything after example.com/ and before the "?"
RewriteEngine on
RewriteCond %{QUERY_STRING} ^productid=1&cat=2&page=1
RewriteRule ^store/product\.php$ http://www.newhost.com/site/Detail?no=1 [R=301,L]
[edited by: jdMorgan at 4:34 pm (utc) on Oct. 17, 2007]