301 Redirect - One Deep Category Issue

Discussion in 'Programming' started by sport302, Feb 20, 2013.

  1. #1
    Hello,

    I am trying to do a simple 301 .htaccess redirect for a webpage that had a one deep category:

    ========================

    Example:

    Redirect 301 /category/page-name/ http://www.xyzwebsite.com/page-name.html

    ========================

    However, I keep getting a page not found error???

    I have done many 301 redirects before, but this is the first time a category was involved.

    Is there a trick to 301 .htaccess redirects when a category is involved?

    Thanks...
     
    sport302, Feb 20, 2013 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    RewriteRule ^category/(.*)$ /$1 [R=301]
    #catches the first instant

    RewriteRule ^category/(.*)/(.*)$ /$2 [R=301]
    #catches the second

    RewriteRule ^category/(.*)/(.*)/(.*)$ /$3 [R=301]
    #catches the third and so on...

    RewriteRule ^category/(.*)/(.*)/(.*)$ /$2/$3 [R=301]
    #you can also do combinations
     
    MyVodaFone, Feb 22, 2013 IP