2 301 www. directs on same server?

Discussion in 'Domain Names' started by Agurus, Mar 7, 2008.

  1. #1
    Hi, I have a linux server and have run into a issue.

    I host 2 websites off of 1 server.

    I did a 301 redirect in the .httacess file on each domain to have it redirct to the www. domain.

    For example when a user goes to:
    site1.com it would redirect them to www.site1.com

    However my second domain it does not work this way, when I go to
    site2.com it redirects me to www.site1.com

    How can I get my second domain to redirect me to www.site 2.com?

    Here is part of my httacess file that deals with redirect for 1 domain, both are same , except where the domain name goes is changed to reflect the domain :p
    
    RewriteCond %{HTTP_HOST} !^www\.site1\.com
    RewriteRule (.*) http://www.site1.com/$1 [L,R=301]
    
    Code (markup):
    Thanks in advance
     
    Agurus, Mar 7, 2008 IP
  2. Agurus

    Agurus Active Member

    Messages:
    252
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    Anyone help me please?
     
    Agurus, Mar 8, 2008 IP
  3. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You'll have to figure out what you're actually trying to achieve. At the moment your rule says:

    1) If the domain someone used is NOT www.site1.com
    2) Then send them to www.site1.com

    www.site2.com is not www.site1.com, so it is dutifully sending them to www.site1.com.

    Perhaps you'd like to instead say:

    1) If the domain someone used IS site1.com
    2) Then send them to www.site1.com
    3) If the domain someone used IS site2.com
    4) Then send them to www.site2.com

    Of course, if someone gets there with www.site3.com or something, then they are left alone.

    To do this you just need:

    RewriteCond %{HTTP_HOST} ^site1\.com
    RewriteRule (.*) http://www.site1.com/$1 [L,R=301]
    RewriteCond %{HTTP_HOST} ^site2\.com
    RewriteRule (.*) http://www.site2.com/$1 [L,R=301]
    Code (markup):
     
    SmallPotatoes, Mar 9, 2008 IP
  4. Agurus

    Agurus Active Member

    Messages:
    252
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    Thanks, to clearify I have 2 httacces files in each directory, one for site 1 and another for site 2. Does this mean to do what you said above to both httacces's
     
    Agurus, Mar 9, 2008 IP
  5. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How can you have two .htaccess files in the same directory?
     
    SmallPotatoes, Mar 10, 2008 IP
  6. Agurus

    Agurus Active Member

    Messages:
    252
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #6
    They are in diffrent dircetories.

    Site 1 is in /root/home/site1/public_html/
    site 2 is in /root/home/site2/public_html/

    each site has its own access, so which one do I edit?
     
    Agurus, Mar 10, 2008 IP
  7. Agurus

    Agurus Active Member

    Messages:
    252
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    Is that OK to do or is there a higher directory?
     
    Agurus, Mar 11, 2008 IP
  8. Agurus

    Agurus Active Member

    Messages:
    252
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #8
    Anyone please help?
     
    Agurus, Mar 12, 2008 IP