Redirect all PROD in CTGY

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Spinner
    Mini Mivite

    • Oct 2011
    • 45

    #1

    Redirect all PROD in CTGY

    Hello,
    I have a MIVA 5.5 PR10 MMUI with CSS store running on an apache server.
    I removed the first letter from 6 categories and all the products in those categories and cleaned up the links that go to them on my 2nd site which has order buttons goint to my MIVA store site. I got over a hundred 404 errors on Bing because of this change even though I cleaned up the links code. I would like to do a general rewrite to redirect them so there are not so many redirects. Would the examples below work…if not, what do I need to do?
    I left off the first part of my URL in examples below (http://mydomain.com/merchant2/merchant.mvc?)


    (I want to redirect category below and all it’s products below from C-DC to just DC) Screen=PROD&Product_Code=C-DC-1234 &Category_Code=C-DC

    Would this be the correct redirect?
    Screen=PROD&Product_Code=C-DC\? &Category_Code=C-DC
    Screen=PROD&Product_Code=DC\? &Category_Code=DC [R=permanent,L]

    Do I also need to do a redirect for the category C-DC to redirect to DC ?
    Thank you in advance for your help!
    Iris
  • ILoveHostasaurus
    Mega Mivite










    • Mar 2006
    • 4998

    #2
    Re: Redirect all PROD in CTGY

    I think you could use:
    PHP Code:
    RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=C-(DC.*)&Category_Code=C-DC
    RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=PROD&Product_Code=%1 [R=301,L] 
    
    That should match on product codes that start with C-DC but should include the DC portion in the part that is turned into a variable, letting you redirect to the new correct URL while keeping the DC plus the rest of the variable. I think that should work but if it doesn't try this instead:
    PHP Code:
    RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=C-DC(.*)&Category_Code=C-DC
    RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=PROD&Product_Code=DC%1 [R=301,L] 
    
    Last edited by ILoveHostasaurus; 10-31-13, 07:07 AM.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment

    • Spinner
      Mini Mivite

      • Oct 2011
      • 45

      #3
      Re: Redirect all PROD in CTGY

      David, Thank you for your reply! I am not a developer so am not sure I understand what the code does.... will the code you provided replace the C-DC with DC in BOTH the Product and Category codes for the products? (I changed C-DC to DC for both category and its product)


      Do I need to do just a regular 301 redirect for the C-DC category to redirect it to DC ?
      Thank you so much for your help!
      Iris

      Comment

      • ILoveHostasaurus
        Mega Mivite










        • Mar 2006
        • 4998

        #4
        Re: Redirect all PROD in CTGY

        In a product URL (Screen=PROD), the Category_Code variable is not necessary; it's typically only there for category breadcrumb use. What the redirect I gave does is issue a redirect from just a product page, where the code starts with C-DC, to a product page, with the C- removed from the front, but preserving the rest of the code.

        Fixing your category pages (Screen=CTGY), assuming the renamed categories went from C-DC(something) to DC(something) would be this:

        PHP Code:
        RewriteCond %{QUERY_STRING} Screen=CTGY&Category_Code=C-DC(.*) 
        RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=CTGY&Category_Code=DC%1 [R=301,L] 
        
        David Hubbard
        CIO
        Miva
        [email protected]
        http://www.miva.com

        Comment

        • Spinner
          Mini Mivite

          • Oct 2011
          • 45

          #5
          Re: Redirect all PROD in CTGY

          David, I apologize for all the questions. It seems really complicated to me.
          I have the old long links from my original mmui store.
          I do have breadcrumb function enabled. For product pages, the URLs look like the code below with both Product and Category codes.
          Since the category code has also changed from C-DC to DC, do I need to do anything different than the code you gave me to address the category code at the end of the product URL ?

          http://store.mydomain.com/merchant2/merchant.mvc?Screen=PROD&StoreCode=ABCD&Screen=PROD&Product_Code=C-DC-1234 &Category_Code=C-DC

          I really appreciate you taking the time to help me with this.
          THANK YOU!
          Iris

          Comment

          • ILoveHostasaurus
            Mega Mivite










            • Mar 2006
            • 4998

            #6
            Re: Redirect all PROD in CTGY

            If you want to keep that the same, try this code instead:

            PHP Code:
            RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=C-DC(.*)&Category_Code=C-DC([^&]*)
            RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=PROD&Product_Code=DC%1&Category_Code=DC%2 [R=301,L] 
            
            You'll notice it looks a little weird at the end of the condition line. What that entire condition line *should* do is say:

            Match on a URL where the query string starts with: Screen=PROD&Product_Code=C-DC
            Match on zero or more characters of any type and store that variable %1 (that's the purpose of the parenthesis)
            Match on &Category_Code=C-DC
            Match on any text that follows that with the exception of the ampersand, and store that in a variable %2

            The reason for that weird part at the end is because there's a chance you may have a URL where even more variables occur after the category code, so we have to exclude matching on ampersands to ensure the category code only picks up what it should and not parts of the next variable.

            The redirect line sends the visitor to the same url that was originally requested but with the product code shortened from C-DC* to DC* and same for the category code in the PROD url.
            David Hubbard
            CIO
            Miva
            [email protected]
            http://www.miva.com

            Comment

            • Spinner
              Mini Mivite

              • Oct 2011
              • 45

              #7
              Re: Redirect all PROD in CTGY

              David, Thank you so much! That looks like exactly what I need.
              I just found some URLs for attributes that end like the code below...will the code you just gave me work for these URLs too?
              merchant.mvc?screen=prod&product_code=c-dc-as1234&attributes=yes
              Thank you!!!!
              Iris
              Last edited by Spinner; 10-31-13, 09:16 AM.

              Comment

              • ILoveHostasaurus
                Mega Mivite










                • Mar 2006
                • 4998

                #8
                Re: Redirect all PROD in CTGY

                Hmm, if you've got product page URL's that sometimes have additional variables after the code, use this instead of what I sent before for the PROD screen:

                PHP Code:
                RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=C-DC(.*)&Category_Code=C-DC([^&]*) 
                RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=PROD&Product_Code=DC%1&Category_Code=DC%2 [R=301,L]
                RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=C-DC(.*)&(.*)
                RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=PROD&Product_Code=DC%1&%2 [R=301,L]
                RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=C-DC(.*)$ 
                RewriteRule ^(.*)$ http://www.domain.com/merchant2/merchant.mvc?Screen=PROD&Product_Code=DC%1 [R=301,L] 
                
                The first block catches your most common occurrence; product pages with category codes included.
                The second block catches your product pages that have 'something' following the product code, and preserves that something but changes the product code.
                The third block catches product pages that have just the product code and nothing more.
                David Hubbard
                CIO
                Miva
                [email protected]
                http://www.miva.com

                Comment

                • Spinner
                  Mini Mivite

                  • Oct 2011
                  • 45

                  #9
                  Re: Redirect all PROD in CTGY

                  David, THANK YOU! That should take care of everything!
                  I appreciate your help!
                  Iris

                  Comment

                  Working...
                  X