I have two sites which runs independently on my VPS, let’s call them site1 and site2.
They are respectively located at /var/www/html/site1
and /var/www/html/site2
I don’t have a domain name yet but I can acces my site using server IP, let’s say its adress is 8.8.8.8
I currently have two separate apache configuration file for each site.
Both sites are configured as follow, only DocumentRoot
and the second Directory
block differs.
<VirtualHost *:80>
ServerName 8.8.8.8
DocumentRoot /var/www/html/site
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html/site>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I can acces both my site by enabling one and disabling the other one.
What I would like to do is to have site1 on http://8.8.8.8 and test site on http://site2.8.8.8.8
I tried the following configuration without success
<VirtualHost *:80>
ServerName 8.8.8.8
DocumentRoot /var/www/html/site1
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html/site1>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName site2.8.8.8.8
DocumentRoot /var/www/html/site2
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html/site2>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Do I need DNS records to be able to achieve my goal ?
I not, how should I configure apache and my VPS to be correctly redirected with either sit1 or site2 depending on the IP prefix ?