Virtual hosts on same ip AND port
6,255
Solution 1
Yes it is possible and quite common, you want name based virtual hosts. There are basically two types virtual hosts, name based and ip based. It gets more complicated with name based if you intended to run SSL, but it is still possible.
It works by looking at the HTTP header in the request to see the domain name being requested.
Solution 2
dont forget to put :
NameVirtualHost 127.0.0.1:80
above vhosts definitions
Solution 3
If the configs are as straight forward as your examples, then you may want to look at mod_vhost_alias
Related videos on Youtube
Author by
Kristaps Karlsons
Updated on September 17, 2022Comments
-
Kristaps Karlsons over 1 year
Is this even possible?
My current vhost.conf entries:
<VirtualHost www2.b-page.lv:80> ServerAdmin [email protected] DocumentRoot "C:/xampp/htdocs/b-page" ServerName b-page ServerAlias www2.b-page.lv ErrorLog "logs/b-page.lv-error.log" CustomLog "logs/b-page.lv-access.log" combined </VirtualHost> <VirtualHost www2.m-page.lv:80> ServerAdmin [email protected] DocumentRoot "C:/xampp/htdocs/m-page" ServerName m-page ServerAlias www2.m-page.lv ErrorLog "logs/m-page.lv-error.log" CustomLog "logs/m-page.lv-access.log" combined </VirtualHost>
hosts file:
127.0.0.1 www2.b-page.lv 127.0.0.1 www2.m-page.lv
These pages will run on the same server, with same CMS. Any help or guides would be very appreciated. Thanks!