I have setup 2 sites at my localhost. One at localhost:8197 and one at fc.localhost:8197 Of course, to make this work, I've edited my /etc/hosts file to include
fc.localhost 127.0.0.1
So, these are my configurations for each site respectively:
000-default.conf (site located at localhost):
<VirtualHost *:8197> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /var/www/html/> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
fc.conf (site located at fc.localhost):
<VirtualHost *:8197> ServerAdmin webmaster@localhost DocumentRoot /home/alex/Documents/fc/Website/fc/html ServerName fc.localhost ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /home/alex/Documents/fc/Website/fc/html> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted </Directory> </VirtualHost>
Suppose that my local IP address is 10.8.210.51 and some pc in my local network puts 10.8.210.51:8197 in the address bar of their browser, then apache on my side will serve the first site (localhost) and not the second one (fc.localhost). The same things happens if I put 127.0.0.1:8197 in my address bar (server-side).
So, my question is, out of clear interest, how does Apache decides which site to serve and how can I change this behavior?