Forum Moderators: phranque

Message Too Old, No Replies

changing shopping cart vendors - need to redirect pages via htaccess

Do I need to redirect every miva variable?

         

Rodney

10:02 pm on Jul 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I'm changing from miva to a different shopping cart script.

I've done most of the conversion, I just need to add an .htaccess redirect so that all of the old catalog pages that are indexed point to the new catalog pages.

After reading through the thread on redirecting (from the WW homepage), I'm a bit confused on which redirect formatting I should use.

Since Miva sometimes adds many variables, I'm not sure how to create an htaccess file that encompasses all the ways that miva links to products.

Here's a sample line from my htaccess:

# Send a redirect from our old file to our new file

redirect permanent h*tp://www.widget-fake-url.com/merchant.mv?Screen=PROD&Store_Code=GOESHERE&Product_Code=PRODUCT01 h*tp://www.widget-fake-url.com/store/product01.html

The problem comes when sometimes Miva interally links to a product, it sometimes adds a &Category_Code=cat01 to the product URL.

So the another URL for the same product above would be:
h*tp://www.widget-fake-url.com/merchant.mv?Screen=PROD&Store_Code=GOESHERE&Product_Code=PRODUCT01&Category_Code=cat01

Is there a way to do a permanent redirect that encompasses anything after the &Product_Code=PRODUCT01 and still redirects it to product01.html?

Hope this makes sense :)

jdMorgan

8:16 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This problem is easily solved usig mod_rewrite:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} Product_Code=([^&]+)
RewriteRule ^merchant\.mv$ http://www.example.com/store/%1.html [R=301,L]

You may or may not need the Options directive at the beginning; Try it with and without that line.

Jim

Rodney

10:57 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But I'm not keeping the Miva .mv URLs anymore. I'm getting rid of that shopping cart all together.

What I'm trying to do is a permanent redirect of all the existing catalog pages to the new shopping carts catalog pages (which just happen to end in .html)

jdMorgan

11:15 pm on Jul 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could have easily modified what I posted, but this should work if I understood your post this time:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} Product_Code=([^&]+)
RewriteRule ^merchant\.mv$ http://www.example.com/%1.html [R=301,L]

This copies the value of the variable named Product_Code into internal variable %1, and then uses it to construct the new URL.

See the references cited in our forum charter [webmasterworld.com] for more information on how to modify this code if necessary after you've tested it.

Jim

Rodney

7:23 pm on Jul 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jim, I appreciate your responses, but I don't think I'm explaining it right.

This copies the value of the variable named Product_Code into internal variable %1, and then uses it to construct the new URL.

The old URL and the new URLs are going to be completely different.

From what I understand of the code you posted, it is making the miva URL and turning it into a static looking URL (that doesn't actually exist).

What I'm trying to do is basically forward all traffic from old page to new totally separate page.

Just like if you had a website where you were changing all of your pages from page1.html, page2.html, page3.html to joe.html, dog.html, help.html.

The existing product URLs have established search engine placement, so I want to make sure those visitors that click on the serps (or any internal links that I forget to change) automatically get forwarded to the completely separate catalog url page that is now up and running.

I apologize if the code you posted does exactly what I just described...I just got the feeling we were talking about 2 different things?

jdMorgan

9:12 pm on Jul 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The code I posted copies the product code from the old URL to the new URL, as you specified in your first post, regardless of whether miva has added other parameters to it. So it redirects from

/merchant.mv?<anything>Product_Code=<any-product-code><anything else>
to
/<any-product-code>.html

This allows many old URLs to be redirected without having to have a unique directive for each old URL.

Is there a way to do a permanent redirect that encompasses anything after the &Product_Code=PRODUCT01 and still redirects it to product01.html?

That is the problem that I addressed.

Jim