Reputation: 25900
I have multiple VirtualHosts in Apache, all listening on port 80 with their ServerNames set to different web addresses. When I go directly to the ip address, Apache sends me to one of those websites as default. I want to change which virtualhost handles requests to the ip address. How would I do this?
<!-- This is currently the default (probably because it's first alphabetically) -->
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mywebsite.com
DocumentRoot /var/www/testingother
...
</VirtualHost>
<!-- I want this to be default -->
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName myotherwebsite.com
DocumentRoot /var/www/testing
...
</VirtualHost>
Upvotes: 0
Views: 618
Reputation: 91792
From my own apache configuration file:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html"
Note that this DocumentRoot
is outside a VirtualHost
block. I would assume you have something similar but if not, you can set it up like that. That would be easier then messing around with the order in which they appear.
Upvotes: 1
Reputation: 18224
Default virtual host is the first one to be loaded.
httpd.conf
or vhosts.conf
, just change the order of vhosts.000-default
.From Apache documentation:
If the request contained an unknown or no Host: header it is always served from the primary name-based vhost (the vhost for that address/port appearing first in the configuration file).
Upvotes: 0