redirecting an entire folder to a specific url with 301?

Discussion in 'HTML & Website Design' started by M.K.Jackson, Jul 15, 2007.

  1. #1
    I'm changing the entire structure of my website and there's a ton of pages that show up in search engines that I would like to do 301 redirects for. I know how to do them for individual files in the .htaccess file, but I was wondering if anyone knew a trick to get the entire contents of a folder to redirect. For example, here is a normal 301 redirect:

    redirect 301 /old/old.htm http://www.you.com/new.htm

    I would like to do this

    redirect 301 /old/ http://www.you.com/new.htm

    I know that code is wrong, but is there a way to do it?

    Thanks!!
     
    M.K.Jackson, Jul 15, 2007 IP
  2. Geoffrey

    Geoffrey Banned

    Messages:
    403
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yeah, replace the old index page with this code:
    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.your.com/new.htm">
    And it will completely redirect to the new folder :)
     
    Geoffrey, Jul 15, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Geoffrey, he wants any request to any file in that directory redirected, not just the index page, and he wants permanent redirects, not meta refreshes.

    Here is the code you need in your htaccess file:
    RewriteEngine on
    RewriteRule ^/old/.* /new.htm [R=301,L]
    Code (markup):
    Or:
    RedirectMatch 301 ^/old/.* http://www.you.com/new.htm
    Code (markup):
     
    krt, Jul 16, 2007 IP
  4. M.K.Jackson

    M.K.Jackson Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks, you rock!!
     
    M.K.Jackson, Jul 16, 2007 IP