Announcement

Collapse
No announcement yet.

301 redirect - new cart?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    301 redirect - new cart?

    Hi,

    I have a quick question on 301 redirect, first a bit of background:

    I'm sorry to say that I'm moving away from Miva Cart after nearly 7 years... I've enjoyed my time with Miva but lately declining sales have led me to find a less costly hosting/cart offer.

    I have my new cart setup a new host/server, what I'm trying to do is setup 301 redirects on that new host that will tell any incoming calls for my old merchant.mvc to look at my new cart. From what I understand I need to do this on a product by product basis AND category by category.

    It's not that huge of task as I only have 50 products and a handful of categories..

    The problem I am encountering is making sure I have this right, as I have not yet pointed the DNS - though I have changed my HOSTS file on my local computer so I can access everything on my new server just fine.

    So, I'm not sure if it's even possible to test this, before pointing DNS, and I would like to know if this looks right, can someone give me a 'yes' or 'no' please?

    Here's the code I'm using (1 of these for each product):
    Code:
    Redirect 301 /Merchant2/merchant.mvc?Screen=PROD&Product_Code=MYPRODUCT1 http://www.mynewserver.com/mynewshop/index.php?l=product_detail&p=3
    Any thoughts? Is this remotely close to what I want to do? Can I test it now, before I point the DNS, or do I have to get the DNS pointed before it will work? When I try now I keep getting a message about trying to 'open' merchant.mvc - and asking me to save the file...

    Thanks in advance,
    -Brett
    Last edited by BrettBGS; 02-02-11, 11:27 PM.

    #2
    Re: 301 redirect - new cart?

    The "open" message is most likely due to moving the files to a server that isn't configured to run Miva Merchant.

    I'll let the .htaccess experts answer your redirect questions.
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

    Comment


      #3
      Re: 301 redirect - new cart?

      Hi,

      I can use RedirectMatch, but it asks me to save my .mvc file.

      I now believe it's a problem with how the server handles .mvc files as it's not a Miva Application running on the new server, my new cart runs as .php.

      Does anyone have any idea how this would be handled on a server that does not support .mvc? I've tried adding .mvc as a MIME type (text/html), but that didn't make any difference...

      TIA,
      -Brett

      Comment


        #4
        Re: 301 redirect - new cart?

        Originally posted by BrettBGS View Post
        Does anyone have any idea how this would be handled on a server that does not support .mvc? I've tried adding .mvc as a MIME type (text/html), but that didn't make any difference...
        You'll need to install MivaVM on that server to properly process .mvc files. MivaVM is a free download now so you could get it form mivamerchant.com and install on the new server to get this issue resolved.

        Comment


          #5
          Re: 301 redirect - new cart?

          Remik,

          You'll need to install MivaVM on that server to properly process .mvc files. MivaVM is a free download now so you could get it form mivamerchant.com and install on the new server to get this issue resolved.
          There's one problem I see with that. I'm moving to a host that does not support, or have the ability to install MivaVM on that host/server. If I am understanding this correctly MivaVM is similar to the old Empressa, is that right? If that is correct, I do not believe the new host will install it, nor would I want it installed, just to handle the 301 redirection...

          I've found one other solution that looks like it will work. I added a MIME type on the mvc files and set them to text/html. This allowed me to setup a Meta Refresh in the the merchant.mvc file that sends it to the new home page of my store. I could do the same for all of the Miva .mvc files in the Merchant2 folder - everything would redirect (through Meta Refresh) to the new storefront on the new server....

          I'm now looking if there is a way I can re-route those meta-refreshes based on Parameters sent on the query string - as when the file is called up with something like:
          Code:
          https://www.mywebsite.com/Merchant2/merchant.mvc?Screen=PROD&Product_Code=MYPRODUCT1
          I should be able to grab the Product_Code off the URL string, correct? Especially if I execute the HTML file in my meta refresh through the PHP processor. If I am able to do that, I can easily write the 50 strings I will need to re-route to the 50 unique products I have based on what is coming on the command line, and then I'm done - at least I hope...

          Does this sound 'workable' to you? I'm surprised it's not come up before....

          Thanks to all in advance,
          -Brett
          Last edited by BrettBGS; 02-03-11, 08:57 PM.

          Comment


            #6
            Re: 301 redirect - new cart?

            You do not need MivaVM at all if all you want to do is redirects. That is done 100% through .htaccess rewrites. I only mentioned you "needed" MivaVM since it sounded like you were trying to execute .mvc scripts and were getting them downloaded through your browser - to fix that and execute (rather than download) those scripts, you need MivaVM. You can install it on your web site even if your host doesn't offer or support it, as long as you have access to your own cgi-bin directory and can manage your own Apache mime extensions.

            The problem with the redirects you are doing is that you are trying to match the whole URL:

            Redirect 301 /Merchant2/merchant.mvc?Screen=PROD&Product_Code=MYPRODUCT1 http://www.mynewserver.com/mynewshop...uct_detail&p=3

            The FROM url includes variables you cannot parse this way - you have to create RewriteCond rules to look for specific parts of the URL - like Product_Code or Category_Code - then use ONLY that variable in the RewriteRule that follows to match the new URL, where you substitute the product code or category code variables. This of course will only work if the new shopping cart has the same product and category codes - matching URLs one-to-one with different codes that do not appear anywhere in the new URL like they did in the old one will not work (or require custom rules for every single page).

            If I'm reading your example above correctly, your old product code is "MYPRODUCT1", but in the new store it's just "3" - so there's nothing in the new URL that you could match against the old URL. If this is indeed the new format you'll be using, you will need to create 50 rules for 50 products, and then for every category page as well.

            I would highly recommend this book if you'd like to learn about rewrites: The Definitive Guide to Apache mod_rewrite - or if you don't have the time, I think hiring a developer for an hour or two might be worth it to get the project done quickly.

            Comment


              #7
              Re: 301 redirect - new cart?

              Remik,

              Thanks a million, I've got it solved. Here's how...

              You do not need MivaVM at all if all you want to do is redirects. That is done 100% through .htaccess rewrites
              That's what I thought. It was someone at my old host who was working with me to get the .mvc files running, which it was never my intention to do, now I see, it's not necessary or needed.

              The problem with the redirects you are doing is that you are trying to match the whole URL

              you have to create RewriteCond rules to look for specific parts of the URL - like Product_Code or Category_Code - then use ONLY that variable in the RewriteRule that follows to match the new URL

              If I'm reading your example above correctly, your old product code is "MYPRODUCT1", but in the new store it's just "3" - so there's nothing in the new URL that you could match against the old URL. If this is indeed the new format you'll be using, you will need to create 50 rules for 50 products, and then for every category page as well.
              That's correct... it was the fact that I was trying to match the whole URL that was messing it up. I gave up on the RewriteMatch command and just went to the RewriteCond / RewriteRule pairs as you will see below.

              You were also correct in that there is NO direct match between the product ID's, so I needed to write new Cond/Rules for each product, not too bad as I only have 50 products, however because I also have separate landing pages for each product I had 100 RewriteCond/RewriteRule pairs to write!

              Here's what I ended up with below... not bad, but done 50 times (1 Landing Page, and 1 Product page) for each product. I also rewrote the category pages too as you suggested.

              Code:
              # LANDING PAGES
              RewriteCond %{QUERY_STRING} Product_Code=MYPRODUCT1landing [NC]
              RewriteRule ^(.*) http://www.mywebsite.com/cat1/product1-landing.html? [R=301,L]
              
              # CART PAGES
              RewriteCond %{QUERY_STRING} Product_Code=MYPRODUCT1 [NC]
              RewriteRule ^(.*) http://www.mywebsite.com/shop/index.php?l=product_detail&p=3 [R=301,L]
              
              # CATEGORY PAGES
              RewriteCond %{QUERY_STRING} Screen=CTGY&Category_Code=AR [NC]
              RewriteRule ^(.*) http://www.mywebsite.com/shop/index.php?l=product_list&c=1 [R=301,L]
              Thank you again for your help... you really triggered the solution, and got me to abandon the RewriteMatch, to go with RewriteCond/RewriteRule pairs and also to stop trying to match the entire URL. After I wrapped my head around it, this morning it only took me 15 minutes to come up with what I needed (and another hour to write them all).

              Thank you,
              -Brett

              Comment

              Working...
              X