Redirecting a domain alias to a directory on same host

Discussion in 'Apache' started by Advertence, Oct 11, 2008.

  1. #1
    Hi,

    Right, I've spent ages on trying to find how to do this and various Google searches have resulted in no solution, wondering if anyone can help.

    I've 3 domains, domain1, domain2 and domain3.

    All 3 domains are hosted on the same hosting account, with domain2 and domain3 being domain aliases that lead to domain1. E.g. if I type in domain2 in the url bar, I get the domain1 site but the domain2 address stays in the url bar.

    Now, I would like to direct each domain to a different directory so it loads up a different looking site. The directory I have is domain1/sites/ so:

    I would like http://domain2.com to result in loading a page from http://domain1.com/sites/domain2.com/ all the while keeping domain2.com in the URL bar, this has to be able to handle any domain alias as I plan on adding more domains.

    This is what I have so far and it does not work:

    
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{HTTP_HOST} (.*)
    RewriteRule ^(.*)$ /sites/%1/$1
    
    Code (markup):
    Thanks for any insight offered!

    Regards,
    Col
     
    Advertence, Oct 11, 2008 IP
  2. vovaNux

    vovaNux Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't think you need an .htaccess solution. Do you have access to your server httpd.conf file? You shouls specify different DocumentRoot parameters for your alias domains. This will solve your issue.
     
    vovaNux, Nov 12, 2008 IP