views:

227

answers:

1

Hello

I've been playing around with this for a couple of hours and have come to the conclusion that asking someone is probably the best way forwards!

I have a fairly out-of-the-box apache install (I've added mod_security and mod_python) so not touched /etc/httpd/conf/httpd.conf

I have a number of domains all running as 's and each with its own individual config file. They are all working as expected except for the fact that any unrecognised hostname will serve the content from the first virtualhost (which I know is the expected behaviour as the content from the first virtualhost is served)

I would like to set up a default set of content to be served if someone reaches my server through an unknown hostname - but in doing so, the first site now also serves this default content which I can't seem to find a reason for.

All of the config files for the individual sites are located in /etc/httpd/conf.d/sites (so that the are not auto-included) and are then included through a file (/etc/httpd/conf.d/sites.conf) which I created - before trying to set up the default server, its content is this:

Include conf.d/sites/*.conf

I modified it to be this to try to get the default server working:

<VirtualHost _default_:80>
        DocumentRoot /home/sites/DEFAULT
        <Directory "/home/sites/DEFAULT">
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
Include conf.d/sites/*.conf

Just to re-iterate the problem - when the second version of sites.conf is active, the first VirtualHost also serves this content; the rest are fine. All of the sites' config files are syntactically correct and have no typos in the ServerNames.

(For reference, I have included the config file for the offending site - stored in /etc/httpd/conf.d/sites/DOMAIN.clintonmontague.co.uk.conf)

<VirtualHost *:80>
        DocumentRoot /home/sites/clintonmontague.co.uk/www
        ServerName clintonmontague.co.uk
        LogLevel emerg
        CustomLog /home/sites/clintonmontague.co.uk/_logs/access_log "combined"
        <Directory "/home/sites/clintonmontague.co.uk/www">
                AllowOverride none
                allow from all
                Options +Indexes
        </Directory>
</VirtualHost>

Sorry for the overly-long question!

Other info: Apache 2.2, CentOS 5, MediaTemple (dv)

A: 

Just for reference - it appears that the problem was because /etc/sysconfig/network reported my HOSTNAME as clintonmontague.co.uk (which happened to be the first domain alphabetically). Therefor, default included that domain name so the default content was being served.

Thought I'd post the answer in case anyone was having similar problems :)

Not possible to change this in MediaTemple (every time the (dv) restarts, it resets this value)

I fixed it by including this line in the default content's index.php

<?php
if ($_SERVER['SERVER_NAME'] == 'clintonmontague.co.uk' )
{
    header ('Location: http://www.clintonmontague.co.uk/');
}
?>
slightlymore