Strange redirect for second vhost domain
Posted: 15. December 2023 16:47
Hello,
I have read a lot of tutorials about creating vhosts on XAMPP but something always seems to fail.
I am using XAMPP with a real domain (SSL) and now I'm adding a second one, which will not have SSL.
This is my current vhosts config:
<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "D:/xampp/htdocs/site2"
ServerName website2.com
ServerAlias website2.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "D:/xampp/htdocs"
ServerName website1.com
ServerAlias website1.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Hosts file:
127.0.0.1 site1.com
127.0.0.1 site2.com
::1 localhost
Website 1 works fine, but website 2 doesn't. When I type the domain name I get redirected to website 1.
The only way it loads is if I type http://site2.com/
If I type anything else like www.site2.com (site2.com > redirects to > site1.com)
(This also might help - when I click on the XAMPP Control Panel -> Apache -> Admin it opens localhost)
Please help!
Thank you.
I have read a lot of tutorials about creating vhosts on XAMPP but something always seems to fail.
I am using XAMPP with a real domain (SSL) and now I'm adding a second one, which will not have SSL.
This is my current vhosts config:
<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "D:/xampp/htdocs/site2"
ServerName website2.com
ServerAlias website2.com
##ErrorLog "logs/dummy-host.example.com-error.log"
##CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
##ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "D:/xampp/htdocs"
ServerName website1.com
ServerAlias website1.com
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Hosts file:
127.0.0.1 site1.com
127.0.0.1 site2.com
::1 localhost
Website 1 works fine, but website 2 doesn't. When I type the domain name I get redirected to website 1.
The only way it loads is if I type http://site2.com/
If I type anything else like www.site2.com (site2.com > redirects to > site1.com)
(This also might help - when I click on the XAMPP Control Panel -> Apache -> Admin it opens localhost)
Please help!
Thank you.