.htaccess redirect help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kitdang
    Mivite


    • Jan 2009
    • 406

    #1

    .htaccess redirect help

    All,

    Need a little help with the conditional redirect.

    My production site format is as follow

    category page - http://www.domain.com/logical_folder/category_code.html
    product page - http://www.domain.com/logical_folder/product_code/product_name.html
    regular page - http://www.domain.com/logical_folder/page_code.html

    My dev site will have this new format which is the same as production except its no longer have the 'logical_folder'. I am using toolkit for the short link.

    category page - http://www.domain.com/category_code.html
    product page - http://www.domain.com/product_code/product_name.html
    regular page - http://www.domain.com/page_code.html

    How do I go about redirect the pages to support the dev site when I switch the dev site live?

    Thanks in advance
  • ILoveHostasaurus
    Mega Mivite










    • Mar 2006
    • 4998

    #2
    Re: .htaccess redirect help

    I think you'd just need:

    # Grab product URL's
    RewriteCond %{REQUEST_URI} ^/logical_folder/([^/]+)/(.*)$
    RewriteRule ^(.*)$ http://www.domain.com/%1/%2 [R=301,L]
    # Everything else
    RewriteCond %{REQUEST_URI} ^/logical_folder/(.*)$
    RewriteRule ^(.*)$ http://www.domain.com/%1 [R=301,L]
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment

    • kitdang
      Mivite


      • Jan 2009
      • 406

      #3
      Re: .htaccess redirect help

      Thanks David. Will those goes at the top above the product and category redirect? Here is what I have in the file. I also notice on all the pages (except for the homepage), the canonical url in the header shows two forward slash after the domain name "http://dev.domain.com//category.html". Not sure if it's caused by the redirect or did I configured it incorrectly in the seo section.

      ### Begin - Inserted by Miva Merchant


      DirectoryIndex /mm5/merchant.mvc


      RewriteEngine On


      RewriteRule ^mm5/admin.mvc? - [QSA,L]






      #Product Rewrite#
      RewriteCond %{REQUEST_FILENAME} !-s
      RewriteRule ^([^/.]+)/([^/.]+).html$ /mm5/merchant.mvc?Screen=PROD&Product_Code=$1 [L,NC,QSA]




      #Category/Page Rewrite#
      RewriteCond %{REQUEST_FILENAME} !-s
      RewriteRule ^([^/.]+).html$ /mm5/merchant.mvc?Screen=TKSL&Code=$1 [L,NC,QSA]


      #RewriteCond %{REQUEST_FILENAME} !-s#
      #RewriteRule ^([^/]+)-p-([^/.]+).html$ /mm5/merchant.mvc?Screen=TKSL&Product_Code=$1&Category_ Code=$2&%{QUERY_STRING} [L]#


      #RewriteCond %{REQUEST_FILENAME} !-s#
      #RewriteRule ^([^/.]+).html$ /mm5/merchant.mvc?Screen=TKSL&Code=$1&%{QUERY_STRING} [L]#




      ### End - Inserted by Miva Merchant

      Comment

      • kitdang
        Mivite


        • Jan 2009
        • 406

        #4
        Re: .htaccess redirect help

        Originally posted by ILoveHostasaurus View Post
        I think you'd just need:

        # Grab product URL's
        RewriteCond %{REQUEST_URI} ^/logical_folder/([^/]+)/(.*)$
        RewriteRule ^(.*)$ http://www.domain.com/%1/%2 [R=301,L]
        # Everything else
        RewriteCond %{REQUEST_URI} ^/logical_folder/(.*)$
        RewriteRule ^(.*)$ http://www.domain.com/%1 [R=301,L]

        The above condition doesn't work. Any suggestion?

        Comment

        • ILoveHostasaurus
          Mega Mivite










          • Mar 2006
          • 4998

          #5
          Re: .htaccess redirect help

          That code is correct; your issue was not related. Rafael should be replying shortly.
          David Hubbard
          CIO
          Miva
          [email protected]
          http://www.miva.com

          Comment

          • kitdang
            Mivite


            • Jan 2009
            • 406

            #6
            Re: .htaccess redirect help

            Thanks David. Appreciate the help

            Comment

            • kitdang
              Mivite


              • Jan 2009
              • 406

              #7
              Re: .htaccess redirect help

              One more question. For those rewrite condition, are they 301 to the new page? Would it impact my google ranking?

              Comment

              • ILoveHostasaurus
                Mega Mivite










                • Mar 2006
                • 4998

                #8
                Re: .htaccess redirect help

                The R=301 in the RewriteRule flags tells it to use a 301.
                David Hubbard
                CIO
                Miva
                [email protected]
                http://www.miva.com

                Comment

                • kitdang
                  Mivite


                  • Jan 2009
                  • 406

                  #9
                  Re: .htaccess redirect help

                  Hi David,

                  Would I still be able to use TKSL page to redirect products when they are discontinue or is TKSL no longer working? I see that the last redirect was comment out and it's part of TKSL. Thanks in advance

                  Comment

                  • ILoveHostasaurus
                    Mega Mivite










                    • Mar 2006
                    • 4998

                    #10
                    Re: .htaccess redirect help

                    You can't redirect one thing to two different destinations. You have two different blocks of code that were both redirecting /<something>.html to a different destination; only the first one would do anything so the second one was commented. I do not know anything about TKSL specifically.
                    David Hubbard
                    CIO
                    Miva
                    [email protected]
                    http://www.miva.com

                    Comment

                    Working...
                    X