redirect subdomains with a 301

Discussion in 'Apache' started by trevorhoare, Apr 14, 2007.

  1. #1
    I am trying to use a 301 redirect to move all subdomains on a domain to another domian.
    Also, if there is a trailing directory, or filename I need to carry that over too.

    So I need to move *.original.com\randomdirectory\randomfile.php to
    *.new.com\randomdirectory\randomfile.php

    I have it working by kind of hacking it out, looking at examples; but was hoping to find "the correct" way to do this, from someone who really knows it.

    Thank you,
    Trev
     
    trevorhoare, Apr 14, 2007 IP
  2. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #2
    Put an .htaccess on each subdomain root with.

    RedirectMatch 301 ^(.*)$ http://newdomain/$1
    Code (markup):
     
    weppos, Apr 16, 2007 IP
  3. trevorhoare

    trevorhoare Active Member

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #3
    I cant put it on each subdomain because there are probably thousands of them, and a lot of them I don't know what they are.
    In talking with people, it seems that this is probably not easily done, for a wildcard situation.


    Thank you for the reply.
    Regards,
    Trev
     
    trevorhoare, Apr 16, 2007 IP
  4. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #4
    The simplest way is to point all your hosts to the same folder/location and configure just a single .htaccess.
     
    weppos, Apr 17, 2007 IP
  5. trevorhoare

    trevorhoare Active Member

    Messages:
    52
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #5
    Yeah, that's the way I have it now; which is fine.
    Thanks for the help,
    Trev
     
    trevorhoare, Apr 17, 2007 IP