If I change the top line of the site.conf file from <VirtualHost *:80> to <VirtualHost www.sitename.co.uk:80> the site renders without reading the .css file or any other file in a subdirectory. Looking at the access.log file I get the following 80.195.213.xxx - - [19/May/2016:18:54:31 +0000] "GET /themes/garland/style.css HTTP/1.1" 404 534 when <VirtualHost www.sitename.co.uk:80> is used but 80.195.213.xxx - - [19/May/2016:19:06:42 +0000] "GET /themes/garland/style.css HTTP/1.1" 200 4470 when <VirtualHost *:80> is used. Why, when I use a specific site url does apache 2.4 fail to read the sub directories?
I can't find anywhere were they talk about this type of setup - are you sure it's valid to use a domain in the VirtualHost declaration? Only thing I can find are *, IP, _default_ - no domain. And why would you want to anyway?
There is an example here https://httpd.apache.org/docs/current/vhosts/examples.html where it gives an example (sorry the formatting is messed up) Listen 80 # This is the "main" server running on 172.20.30.40ServerName server.example.comDocumentRoot"/www/mainserver" <VirtualHost172.20.30.50> DocumentRoot"/www/example1" ServerName www.example.com # Other directives here ... </VirtualHost>
Actually you are right, there are no url's in this part, just IP addresses. thanks for making me read the example again. I was actually trying to get one virtual host for both www.example.com and example.com.
If you need one virtual host for both with and without www. just make a ServerAlias in the VirtualHost?