perm redirect all subdomain to www.

Discussion in 'Apache' started by gford, Dec 20, 2005.

  1. #1
    Hi all,

    I want to redirect all traffic for all files from:
    
    subdomain.domain.com
    
    to
    
    www.domain.com
    
    Code (markup):
    how do i do that in .htaccess? Thanks in advance!
     
    gford, Dec 20, 2005 IP
  2. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I use this:

    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^zindy.zone.dk
    RewriteRule ^(.*) http://zindy.zone.dk/$1 [L,R=301]
    
    Code (markup):
    It redirects everything that isn't the intented sitename, which enabels me to use a catch all cname so it doesn't matter what you type infront of the domain, you'll still hit the right pages.

    If that isn't what you're looking for maybe this is:

    
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^subdomain.domain.com
    RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]
    
    Code (markup):
    Maybe you want to add www.subdomain.domain.com too.
     
    blinxdk, Dec 20, 2005 IP
  3. gford

    gford Peon

    Messages:
    1,188
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks I will give it a try tomorrow!
     
    gford, Dec 20, 2005 IP
  4. gford

    gford Peon

    Messages:
    1,188
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That worked nicely! Thanks!
     
    gford, Dec 21, 2005 IP
  5. seobrazilian

    seobrazilian Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hi i dont undestand please help me

    a need hundreds subdomains for example
    i need that my allsubdomains.webspace.com.br redirect to www.webspace.com.br

    is possible? *.webspace.com.br to www.webspace.com.br
     
    seobrazilian, Nov 3, 2008 IP