Announcement

Collapse
No announcement yet.

Shorten URL

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

    Shorten URL

    I have ALMOST got my short links setup and my old links 301d to the new short link BUT.... Im stuck... again.

    Trying to get this

    ht tp://mywebsite.com/mm5/merchant.mvc?Screen=PROD&Store_Code=HTE&Product_Co de=sample&Category_Code=SampleCat

    to look like this

    ht tp://mywebsite.com/PROD/sample.htm


    instead I get this

    ht tp://mywebsite.com/PROD/sample&Category_Code=SampleCat.htm


    I'm using this

    RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=(.*)$
    RewriteRule ^(.*)$ http://mywebsite.com/PROD/%1.htm? [R=301,L]


    RewriteCond %{QUERY_STRING} ^Screen=PROD&Store_Code=HTE&Product_Code=(.*)$
    RewriteRule ^(.*)$ http://mywebsite.com/PROD/%1.htm? [R=301,L]


    What do I need to strip that category off the end?

    Thank you so much in advance!
    Last edited by AaronM; 05-27-14, 09:29 AM.

    #2
    Re: Shorten URL

    Change it to this:

    RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=(.*)&
    RewriteRule ^(.*)$ http://mywebsite.com/PROD/%1.htm? [R=301,L]
    RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=(.*)$
    RewriteRule ^(.*)$ http://mywebsite.com/PROD/%1.htm? [R=301,L]

    RewriteCond %{QUERY_STRING} ^Screen=PROD&Store_Code=HTE&Product_Code=(.*)&
    RewriteRule ^(.*)$ http://mywebsite.com/PROD/%1.htm? [R=301,L]
    RewriteCond %{QUERY_STRING} ^Screen=PROD&Store_Code=HTE&Product_Code=(.*)$
    RewriteRule ^(.*)$ http://mywebsite.com/PROD/%1.htm? [R=301,L]

    The issue you're having is that the .* followed by $ means capture everything after Product_Code= and use that as the product code, so it's using "sample&Category_Code=SampleCat" as your product code. Changing it to ampersand will get only what you want because it's only going to match up to the ampersand. Duplicating what you already had right after that will ensure that if you do have some URL's sitting out there that actually do end with the code, that they still redirect too.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment


      #3
      Re: Shorten URL

      Thank you so much David! That worked perfectly!

      Comment

      Working...
      X