Redirect domains to www

Discussion in 'Apache' started by Rub3X, Apr 9, 2007.

Thread Status:
Not open for further replies.
  1. #1
    Rub3X, Apr 9, 2007 IP
  2. Rub3X

    Rub3X Well-Known Member

    Messages:
    1,902
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    135
    #2
    RewriteCond %{HTTP_HOST} ^www\.(.+)\.(com|net|org|edu|info) [NC]
    RewriteRule ^(.*) http://$1.$2 [L,R=301]


    Something like this that actually works is what I need.
     
    Rub3X, Apr 9, 2007 IP
  3. Monty

    Monty Peon

    Messages:
    1,363
    Likes Received:
    132
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Something like that ?

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^example.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    Code (markup):
     
    Monty, Apr 9, 2007 IP
  4. Rub3X

    Rub3X Well-Known Member

    Messages:
    1,902
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    135
    #4
    Is there a way so I don't have to put it in each vhost
     
    Rub3X, Apr 9, 2007 IP
  5. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    Code (markup):
    Should redirect every domain (and subdomains) to the WWW version.
     
    rodney88, Apr 10, 2007 IP
Thread Status:
Not open for further replies.