If you have a single IP and 2( or more)domain name then you can configure Name based Virtual hosting.
The below example is Checked version Apache 2.2
Sample Windows Host file entry
localhost bala.test1.corp.com
127.0.0.1 bala.test1.corp.com
localhost bala.test2.corp.com
127.0.0.1 bala.test2.corp.com
httpd.config Entry
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
DocumentRoot C:/BALA/Apache/htdocs/e-Shop
ServerName bala.test2.corp.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/BALA/Apache/htdocs/individual
ServerName bala.test1.corp.com
# Other directives here
</VirtualHost>
Once all these configurations are done restart your Apache server
You can hit the url you will be able to see the two different sites as configured.
Problem faced,
VirtualHost 127.0.0.1:0 overlaps with VirtualHost 127.0.0.1:0, the first has precedence, perhaps you need a NameVirtualHost directive - then it took same doc room for both the site. Then changed to name based virtual hosting than IP based.
Name based Virtual Hosting - Multiple IP and Multiple domain name
# This is the "main" server running on 172.xx.xx.xx
ServerName server.example.com
DocumentRoot /www/mainserver
<VirtualHost 172.xx1.xx1.xx1>
DocumentRoot /www/example1
ServerName www.example.com
# Other directives here ...
</VirtualHost>
<VirtualHost 172.xx2.xx2.xx2>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here ...
</VirtualHost
No comments
Post a Comment