Apache: 2 domains/1 doc root?

TommyWillB

Registered
I have two domain names that I want to point at the same document root. Basically I want this site to work exactly the same regardless of which domain name you entered using.

So I have the site set up as domain #1 and a virtual set up with domain #2. Domain #1 has these settings:
Code:
ServerName (domain name #1)
DocumentRoot "/Library/WebServer/Documents"
.
.
.
<IfModule mod_dir.c>
    DirectoryIndex index.php index.html
</IfModule>
The virtual is set up like this:
Code:
<VirtualHost *>
    ServerName (domain name #2)
    DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>
So the problem I am having is with this virtual.

When I first enter the site with domain #2 it looks fine... Links with filenames and trailing slashes work fine. But if I hit a link with no trailing slash then suddenly I am popped back to Domain #1.

I thought the ServerName comman was supposed to keep that from happening.

What am I doing wrong?
 
OOPS!!!!!!

Domain #1 and domain #2 are VERY similar... It turned out that I had domain #1 lists both in the main block AND the virtual.

Consequently domain #2 was not even explicity set up and was only working because that's the default nature of Apache.




I hope there is something here that other folks can learn from, becuse I sure feel stupid...
 
Back
Top