Redirect old subdomain

Discussion in 'Site & Server Administration' started by Alan|AzH, Aug 28, 2011.

  1. #1
    I have a small issue I'm hoping you guys can help with.

    I used to have forums.alienscolonialmarines.net set up as the domain for my forums. About a year ago I changed it to alienscolonialmarines.net/forums but kept the subdomain active as some people were still using it and Google still listed it.

    Now I have a need to redirect all traffic to that subdomain to the relevant page on the new domain, so when someone goes to:

    http://forums.alienscolonialmarines.net/search.php?do=getnew

    They are redirected automatically to:

    http://alienscolonialmarines.net/forums/search.php?do=getnew

    And likewise for all other pages in my forum.

    I'm sure having two different versions isn't helping my SEO rankings at all either!

    Assume I can add a file php or otherwise to the folder for the subdomain to cause an auto and instant redirect to the correct page on the forums. Any suggestions?

    Thanks.
     
    Alan|AzH, Aug 28, 2011 IP
  2. alexdoerr

    alexdoerr Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    As far as I understand you correctly, you want to redirect the subdomain to subfolder. This could be done by making changes in the code to:-
    RewriteCond %{HTTP_HOST} !^(www|ftp|mail)\.example\.com
    RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
    RewriteRule (.*) /subd_%1/$1 [L]


    This will redirect the subdomain to subfolder.
     
    alexdoerr, Aug 28, 2011 IP
  3. chtdatweb

    chtdatweb Well-Known Member

    Messages:
    1,473
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Yep a simple HTACCESS 301 redirect is the best way. Then make sure you have both domains in webmaster tools and then do a change of address. This then should prevent any problems in SERPS.
     
    chtdatweb, Aug 31, 2011 IP