Subdomain redirect

Discussion in 'Apache' started by cupid, Jul 12, 2006.

  1. #1
    I have the following:

    domain2.domain1.com

    Need to redirect from:
    domain2.domain1.com -> www.domain2.com

    How do I do this?
     
    cupid, Jul 12, 2006 IP
  2. Mystique

    Mystique Well-Known Member

    Messages:
    2,579
    Likes Received:
    94
    Best Answers:
    2
    Trophy Points:
    195
    #2
    Add to your .htaccess file:
    
    Redirect  /domain2.domain1.com http://www.domain2.com
    
    Code (markup):
    That does the trick ;)

    for Search Engine purposes you can instruct them adding 301 if this is a permanent redirection
    
    Redirect 301 /domain2.domain1.com http://www.domain2.com
    
    Code (markup):
     
    Mystique, Jul 12, 2006 IP
  3. Jean-Luc

    Jean-Luc Peon

    Messages:
    601
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would use this .htaccess in domain1.com :
    Options +FollowSymlinks
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^domain2.domain1.com$ 
    RewriteRule ^(.*) http://www.domain2.com/$1  [QSA,L,R=301]
    Code (markup):
    Jean-Luc
     
    Jean-Luc, Jul 12, 2006 IP