Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been having a really weird problem with Apache's virtual host config. I have 2 domain names (domain1.com domain2.com) . The problem is when someone goes to domain2.com, once in a while they will suddenly see the index.html page from domain1.com but without all the css (just html links). The issue is driving me nuts! Any help would be appreciated.

Here is my virtual host for domain1

<VirtualHost *:80>
ServerAdmin me@domain1.com
DocumentRoot /var/www
ServerName www.domain1.com
ServerAlias domain1.com *.domain1.com
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options  FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options  MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

and here is the config file for domain2.com is the same thing except the following

    ServerAdmin me@domian1.com
DocumentRoot /var/www/domain2
ServerName www.domain2.com
ServerAlias domain2.com *.domain2.com
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/domain2r>
    Options  FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Is "once in a while" reproducible on certain links for example? It might be a link pointing to a page on your server (with a typo) that does not hit domain2.com but the default virtual server that might by default also sit in /var/www.

To debug this you should have the default virtual server serve from a different directory than domain1.com (or create a default server at all, otherwise I guess that the first defined server might be the default)

Just a side note - Just for style I'd serve domain1.com and domain2.com from directories that are not subdirectories of each other.

Note that you can also embed <base href="http://domain1.com"> in the head section of your documents and search for days on the protocol level while it's a problem caused by HTML.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.