I have several name-based virtual hosts on my Apache server. As I understand it, if the IP/port is matched, but the client supplies a blank or unknown host name, the first virtual host will be used. That does seem to be happening, but if I shuffle around the order, some virtual hosts will correctly display when accessed at, for instance, localhost, but two of them appear to return a redirect. The config files for one that works and one that don't work look exactly the same:
<VirtualHost *:80> #This is a simple site consisting of static pages. ServerName www.static.com ServerAlias static.com *.static.com DocumentRoot /var/www/static </VirtualHost> <VirtualHost *:80> #This is a WordPress site. ServerName www.wordpress.com ServerAlias wordpress.com *.wordpres.com DocumentRoot /var/www/wordpress </VirtualHost>
(Actual URLs removed.) Putting the static site first and accessing localhost gets this in the logs:
www.static.com:80 127.0.0.1 - - [09/Aug/2012:23:33:58 -0400] "GET / HTTP/1.0" 200 1676 "-" "Lynx/2.8.8dev.5 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.8.6" "Host: localhost"
And it works fine. (It also works just fine with another static site I have.) Doing the same with the WordPress site gets this:
www.wordpress.com:80 127.0.0.1 - - [09/Aug/2012:23:32:50 -0400] "GET / HTTP/1.0" 301 379 "-" "Lynx/2.8.8dev.5 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/2.8.6" "Host: localhost"
Lynx tries localhost, then gets a 301, and then tries http://www.localhost/ (which doesn't work, obviously). The same things happens with 127.0.0.1, the server's local IP address, or a random name set in my hosts file to point to the server.
Also, I don't think it's just a Wordpress thing, because the exact same thing happens with a Django site I also have.
Thanks in advance for any ideas.