.htaccess and mutiple domains

Discussion in 'Apache' started by wabbit, Aug 22, 2006.

  1. #1
    Hi all,

    Newbie question....

    I have two domain names registered with CompanyX. I have one domain hosting account with CompanyY.

    Is it possible for me to point both domain names (via DNS) to the same server at CompanyY and use .htaccess (or another method) to redirect the user to the right web page with the proper URL in the address bar?

    i.e.

    DNS:
    www.domain1.com --> 123.123.123.123
    www.domain2.com --> 123.123.123.123

    On web host : i.p. 123.123.123.123
    .htaccess redirects requests for www.domain1.com to /domain1/index.html and requests for www.domain2.com to /domain2/index.html

    In both cases, the 'proper' URL will appear in the browser address bar, and search engine indexes etc?

    If this is not clear, then please ask for me to clarify my problem.

    Any help is appreciated.

    Cheers
     
    wabbit, Aug 22, 2006 IP
  2. Brilliances

    Brilliances Active Member

    Messages:
    619
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I haven't tried this myself before but isn't this what happens when you add on a domain to an account. So domain2.com will point to a http://domain2.domain1.com or http://domain1.com/domain2/ but still look like http://www.domain2.com to the user.

    I'm new to mod_rewrite too but from what I've read so far, I believe that something like this should work:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^http://www.domain2.com [NC]
    RewriteCond %{HTTP_HOST} ^http://domain2.com [NC]
    RewriteRule ^/(.*)$ http://domain1.com/domain2/$1 [L]
     
    Brilliances, Aug 26, 2006 IP