I came across a stupid problem the other day while trying to figure out why my site changes weren’t showing up.

I’m writing my problem and solution on my blog so I’ll remember and not screw up the same way again.

Consider the following virtual host files.


<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias *.example.com

    . . .



<VirtualHost *:80>
    ServerName staging.example.com
    ServerAlias *.staging.example.com

    . . .


My goal is to have www.example.com and anything.example.com point to one vhost with the exception of staging.example.com and anything.staging.example.com. The problem is that Apache loads the scripts in order by file name. So when the second virtual host is loaded Apache pretty much ignores it because *.example.com overrides staging.example.com.

I changed my file names of my vhost files, reloaded Apache, and all was fixed.

The correct file names:

[ad#Google Adsense 728×90]