301 redirect - Question

Discussion in 'Site & Server Administration' started by dmi, Apr 10, 2009.

  1. #1
    Hi,

    I have a little "situation" that I can't resolve.

    Let's say I have a site X.com. Now, on that site there is a forum, which is on a subdomain (forum.x.com). Now, that forum has thousands of pages, but they are all going to be taken down. Is there a way to do a 301 redirect of ALL pages that are under forum.x.com/* ? It would be too much to do it one by one.

    I will rep anyone who can offer a solution.

    Thanks,
    dmi
     
    dmi, Apr 10, 2009 IP
  2. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #2
    Yes, it is possible. Just add following code in your .htaccess file present in your root directory:

    rewritecond %{http_host} ^forum.x.com [nc]
    RewriteRule ^(.*)$ http://NEW_WEB_SITE_URL/$1 [r=301,nc]

    Kailash
     
    kailash, Apr 10, 2009 IP
  3. dmi

    dmi Well-Known Member

    Messages:
    2,705
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Thank you very much. How about the code for redirect everything from x.com/something ? Is it like this?

    rewritecond %{http_host} ^x.com/something [nc]
    RewriteRule ^(.*)$ http://NEW_WEB_SITE_URL/$1 [r=301,nc]

    ?
     
    dmi, Apr 11, 2009 IP
  4. kailash

    kailash Well-Known Member

    Messages:
    1,248
    Likes Received:
    42
    Best Answers:
    0
    Trophy Points:
    190
    #4
    Yes, it should work.

    Kailash
     
    kailash, Apr 11, 2009 IP