.htaccess rewrite code help please

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

    • Oct 2011
    • 45

    #1

    .htaccess rewrite code help please

    Hello, I am ready to launch my MIVA CSSUI dev site. It will replace my live MMUI site. Both sites are MM5.5 with the latest PR version and updates.
    The live site Product URL with the long links looks like this:



    http:// (I put this space her because it is shortening my URL when I preview it)
    store.mydomain.com/merchant2/merchant.mvc?Screen=PROD&Store_Code=BSAW&Product_C ode=S-SC-WS6502&Category_Code=SC
    There is also no space in Product_Code but it is being shown in the preview with a space after the C



    The dev site with short links product URL looks like this:


    I am not a developer and do not know how to write the code for this. Please can someone provide the code I would need to use to do this?

    I need help with the correct rewrite code for my .htaccess file to go from one to the other. I have 800+ products. Since the dev site does not have the CTGY code in the URL, would it be possible to have a rewrite code that would redirect every product from the old site to the new site with short links by putting something at the end of the rewrite code telling it to ignore the Category_Code="whatever that code might be" or would there need to be a rewrite code for all 75 categories to each be ignored?

    Is it better for SEO purposes to do individual 301 redirects for all 800 products? I do not know how many 301 redirects is too many for the spiders to deal with.

    On my categories, the name of the categories will be changing so I will need to do a 301 redirect for all the categories. Do I just do a standard 301 redirect from one URL to another URL for each one?
    Thank you in advance for any help or suggestions you can give me.
    Sincerely, Iris
  • ILoveHostasaurus
    Mega Mivite










    • Mar 2006
    • 4998

    #2
    Re: .htaccess rewrite code help please

    You can't use standard 'Redirect' commands if the old url is a long format url like merchant.mvc?Category=BLAH&Screen=CTGY, those require full rewrites; so you'll need one of those for every single category if the codes are all changing. It would look something like this:

    RewriteCond %{REQUEST_URI} /mm5/merchant.mvc
    RewriteCond %{QUERY_STRING} Screen=CTGY&CategoryCode=OLDCODE
    RewriteRule ^(.*)$ http://www.mydomain.com/C/NEWCODE.html? [R=301,L]

    Hopefully your product codes are staying the same; then this is all you need for all 800 to be covered:

    RewriteCond %{REQUEST_URI} /mm5/merchant.mvc
    RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=(.*)&
    RewriteRule ^(.*)$ http://www.mydomain.com/P/%1.html? [R=301,L]
    RewriteCond %{REQUEST_URI} /mm5/merchant.mvc
    RewriteCond %{QUERY_STRING} Screen=PROD&Product_Code=(.*)$
    RewriteRule ^(.*)$ http://www.mydomain.com/P/%1.html? [R=301,L]

    The reason there are two is because one will pick up when there are further arguments after the product code, the other will pick up when the code ends the string. The question mark after html is necessary to make sure the browser doesn't re-add the query string; doubling it.

    These rewrites should occur above the standard Merchant short link code that will also be in the .htaccess.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment

    • Brennan
      Super Moderator









      • Jun 2009
      • 3481

      #3
      Re: .htaccess rewrite code help please

      We did an inforgraphic a while back to help explain what all this means. Maybe helpful here if you want to dig into the .htaccess syntax

      Brennan Heyde
      VP Product
      Miva, Inc.
      [email protected]
      https://www.miva.com

      Comment

      • Spinner
        Mini Mivite

        • Oct 2011
        • 45

        #4
        Re: .htaccess rewrite code help please

        Thank you so much for helping me with this.
        I have thought of another question.
        If I want to change some of the product codes to be more SEO friendly using the product name instead of the product code and I have used the rewrite code you have provided, how do I handle that?
        If I do a separate 301 redirect for several of the products that are covered in the rewrite code, what effect does this have?
        Or would it not work anyway because of the rewrite code?
        If I can put some 301 redirects on some of the products, do I put it before or after the rewrite code for products?
        Thank you!
        Sincerely, Iris

        Comment

        • Spinner
          Mini Mivite

          • Oct 2011
          • 45

          #5
          Re: .htaccess rewrite code help please

          Brennan, Thank you! That looks like it will be very helpful in understanding how the rewrites work.
          Sincerely, Iris

          Comment

          • Spinner
            Mini Mivite

            • Oct 2011
            • 45

            #6
            Re: .htaccess rewrite code help please

            David, My goodness, it really gets complicated. I just thought of a couple of other things.
            At the same time I launch my CSSUI site, I will be doing away with my static site mydomain.com
            I will be writing individual 301 redirects for all the categories. All the products on the static site have order buttons which link to the store.mydomain.com site. I am assuming that these hard coded links with long urls will be taken care of with the previous rewrite codes that you gave me, is that correct? Or do I need another rewrite code because these long url links are on my static site?
            There are over 2000 images on the static site
            Their URLs look like this
            mydomain.com/images/folder/image-name.jpg or .png or .gif
            There are a lot of folders holding the images, all with different folder names
            Can you please provide the rewrite code for the images too?

            Do I also need to have a rewrite code for the images going from
            http://store.mydomain.com/graphics/00000001/image name
            to redirect to
            http://mydomain.com/graphics/00000001/image name

            And one last somewhat unrelated question...does the graphics folder have to have the 00000001, or can that be shortened or eliminated? I only have one store.
            Thank you for all your wonderful help! I really appreciate it!
            Sincerely, Iris

            Comment

            • lesliekirk
              Super Moderator











              • Aug 2008
              • 9289

              #7
              Re: .htaccess rewrite code help please

              Originally posted by Brennan View Post
              We did an infographic a while back to help explain what all this means. Maybe helpful here if you want to dig into the .htaccess syntax

              http://www.mivamerchant.com/images/b...-access-02.jpg
              This is fabulous! Now a repository of htaccess rewrites is needed. I've searched and searched the forum for the rewrites that will direct existing long URLs to short URLs. I seem to recall there were two versions and I have had issues with both

              Leslie
              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: X | Facebook | Pinterest

              Comment

              Working...
              X