Announcement

Collapse
No announcement yet.

301 redirect in htaccess

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

    301 redirect in htaccess

    Looking for some advice on 301 redirects trying to eliminate external page (not Miva pages) requests.

    This works:

    Redirect 301 /misc/ http://mydomain.com/mm5/merchant.mvc...SC&screen=CTGY

    We want this next one to resolve in the upper level category MISC. But This doesn't work:

    Redirect 301 /misc/oldmiscpage.htm http://mydomain.com/mm5/merchant.mvc...SC&screen=CTGY

    The result is a not found page because oldmiscpage.htm is being concatenate to the new URI, so the NTFD message is that CTGYoldmiscpage.htm isn't found. The same NTFD renders when using a sub-directory.

    Redirect 301 /misc/sub1misc http://mydomain.com/mm5/merchant.mvc...SC&screen=CTGY

    The NTFD message is that CTGYsub1misc isn't found.

    So, I can only use one folder that redirects as expected.

    Every example and instruction I've found has me thinking the scenario should work as planned. But doesn't seem to work.

    Extending the question, Idealy, these external pages will have a pattern of /misc/*.htm to be redirected. I'd like to be able to use a wildcard scenario to handle all the sub-directories and files in 1 redirect command if it is possible.

    This has evolved into trying something like this:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^([^/.]+).htm$ http://mydomain.com/mm5/merchant.mvc?Store_Code=MYCODE&screen=CTGY&categor y_code=$1-CTGYSTRCODE [R=301,NC]

    because the uri can have sub folders as in: /misc/oldmiscpage.htm, I've also tried:

    RewriteRule ^([^/]+)/([^/.]+).htm$ http://mydomain.com/mm5/merchant.mvc?Store_Code=MYCODE&screen=CTGY&categor y_code=$2-CTGYSTRCODE [R=301,NC]

    What are other things I could try/do?


    Thanks,

    Scott
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    #2
    Re: 301 redirect in htaccess

    First thing; more specific redirects should always come before less specific. So you'd want:

    Redirect 301 /misc/oldmiscpage.htm...
    Redirect 301 /misc/sub1misc...
    Redirect 301 /misc/...

    Additionally, if your site is set up to make use of short links via internal rewrites, the redirects must come before those rewrites in the .htaccess file. If you can instead just use two rewrites, that should work, but again, must come above the rewrites that make the short links work. If your store is using short links, the two rewrites you mentioned would be incorrect; you'd want to redirect to the equivalent new short link rather than the long merchant.mvc?Screen=.... long link.

    I'd probably do them like:

    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteCond %{REQUEST_URI} ^/misc/.*([^/.]+).htm$
    RewriteRule ^(.*)$ http://mydomain.com/mm5/merchant.mvc?Store_Code=MYCODE&screen=CTGY&categor y_code=$1 [R=301,NC]

    That should work for both /misc/page.htm and /misc/sub1/page1.htm.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment


      #3
      Re: 301 redirect in htaccess

      Thanks David. I appreciate the help here. This looks like it will cover my scenario.

      Scott
      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment

      Working...
      X