Need Some Quick .htaccess Help

Discussion in 'Site & Server Administration' started by patrich, Mar 6, 2009.

  1. #1
    I removed an old directory from my website and now of course google is showing a bunch of 404 error pages that I would like to clean up. Basically, I have a bunch of dead links that are like this:

    http***mydomain.com/directory/detail/link-1.html

    http***mydomain.com/directory/detail/link-2.html

    http***mydomain.com/directory/detail/link-3.html

    and I would like to 301 redirect them to this:


    http***mydomain.com/directory/

    I know this is a relatively easy redirect, but it has been so long since I messed with any .htaccess files I can't get it to work. Anyone know how to do this?

    Thanks for your help!
     
    patrich, Mar 6, 2009 IP
  2. starkman

    starkman Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There's two ways to solve this out ;)

    One is to use ErrorDocument 404 and redirect it to your main directory/domain. This way, any and all 404 errors will automatically redirect to your main domain/directory.

    The second, (.htaccess) should be something along these lines:

    
    RewriteEngine On
    RewriteRule ^directory/detail/(.*)$ directory/ [L]
    
    Code (markup):
    Code above assumes the subdirectory detail is now obsolete and no longer in use thus being redirected to the subdirectory directory
     
    starkman, Mar 6, 2009 IP
  3. patrich

    patrich Peon

    Messages:
    142
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Awesome, thanks for the help starkman! I knew that there was a fairly simple fix for this, just couldn't figure it out on my own.
     
    patrich, Mar 6, 2009 IP
  4. starkman

    starkman Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Cheers :)
    My pleasure :0
     
    starkman, Mar 6, 2009 IP