Mass 301 redirect htaccess

Discussion in 'Apache' started by Adam Kelly, May 11, 2013.

  1. #1
    I've not seen an answer for this mass 301 redirect issue specifically... Can anyone let me know how to do this....

    category/brand URLs:

    redirect: /ID-some-brand (e.g. /43-religion-clothing or /26-ichiban) to: /some-brand (e.g. /religion-clothing or /ichiban)

    Product URLs:

    redirect: /some-category/ID-some-product-name.html (e.g. /mens-sweat-shirts/1543-ichiban-fairly-offensive-sweat-in-grey.html)

    to: /some-product-name (e.g. /ichiban-fairly-offensive-sweat-in-grey)

    We have 1,090 products and 60+ categories so some form of .htaccess trick would be amazing to know. If anyone could provide me with what I could put in the .htaccess to accomplish this I would be eternally grateful!
     
    Adam Kelly, May 11, 2013 IP
  2. Zarko Dimitrov

    Zarko Dimitrov Greenhorn

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    This should do the trick :
    
    RewriteEngine on
    RewriteBase /
    #brand
    redirectMatch 301 ^/([0-9]+)-([^/.]+)$ http://www.yourdomain.com/$2
    #product
    redirectMatch 301 ^/([^/.]+)/([0-9]+)-([^/.]+)\.html$ http://www.yourdomain.com/$1/$3
    
    Code (markup):
     
    Zarko Dimitrov, Jun 6, 2013 IP