Forum Moderators: phranque

Message Too Old, No Replies

Help re-writing older MIVA URLs to non-MIVA store

Trying to setup perm. 301 redirects to non-MIVA pages.

         

gatonegro

8:46 pm on Nov 22, 2006 (gmt 0)

10+ Year Member



I started a topic in the supporters forum, but I didn't get a solution that worked.

You can view the existing discussion here:
[webmasterworld.com...]

Basically, we have a site that used to use MIVA (/Merchant2/ folder variety). The site now uses X-Cart, so we want to setup permanent 301 redirects from each MIVA URL to the corresponding URL in X-Cart.

We've tried setting up an .htaccess file in the /Merchant2/ folder, but that didn't work. Everything we've tried so far hasn't worked; it comes up page not found, or redirects to our custom 404 error page (if directive is present in .htaccess).

Looking for help...

Thanks
Cory

bhartzer

8:48 pm on Nov 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried putting the .htaccess file in the root folder and not in the /merchant2 folder?

gatonegro

8:53 pm on Nov 22, 2006 (gmt 0)

10+ Year Member



Yes, we tried that first and when it didn't work, another member suggested creating an .htaccess file specifically for the /Merchant2/ folder.

Neither solution worked.

jdMorgan

9:16 pm on Nov 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The main problem with the code itself is that RewriteRule cannot "see" a query string. So try something like this in the same directory as the merchant.mv file (you may still have an Alias directive in your server config which diverts miva requests to that directory).

RewriteEngine on
Options +FollowSymLinks
#
RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=product1$
RewriteRule ^merchant\.mv$ http://www.example.com/Product1-p-16133.html [R=301,L]

If this doesn't work, and if you don't have any other currently-working rewrites, then it may be time to take a step back and test a very simple rule, such as:

RewriteRule ^foo\.html$ http://www.example.com/bar.html [R=301,L]

If you request foo.html from your site, then you should see your browser address bar change to bar.html, whether or not the subsequent request for bar.html results in a 404 error.

Jim

[edited by: jdMorgan at 9:16 pm (utc) on Nov. 22, 2006]

gatonegro

11:00 pm on Nov 27, 2006 (gmt 0)

10+ Year Member



Ok, so the redirect is now working at 90%... (thanks a ton).

I'm now seeing a new problem w/ the query string that I need to fix because I don't want Google passing the value to the wrong page or indexing the page with the query string.

Here's what I have in my .htaccess file:
RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=product1$
RewriteRule ^merchant\.mv$ [mywebsite.com...] [R=301,L]

Here's the URL that it's redirecting to (notice the unwanted query string):
[mywebsite.com...]

How do I write the rewrite rule to omit the query string info from the new URL?

Thanks

jdMorgan

4:07 am on Nov 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add a question mark to the end of the substitution URL to clear the query string; This question mark will not appear in the redirected URL.

RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=product1$
RewriteRule ^merchant\.mv$ http://www.example.com/product1.ht[b]ml?[/b] [R=301,L]

Jim

gatonegro

8:02 pm on Nov 28, 2006 (gmt 0)

10+ Year Member



I've successfully been able to redirect the URLs.

Thank you so much for the help!