I've set up two projects for two different vhosts and the problem is that no matter which URL I try to open, I'll be redirected to the first one.
Windows hosts file:
127.0.0.1 myfirst-project.local
127.0.0.1 mysecond-project.local
Apache vhost file:
<VirtualHost myfirst-project.local:80>
DocumentRoot "D:\projects\first"
ServerName myfirst-project.local
ErrorLog "logs/first-error.log"
CustomLog "logs/first-access.log" common
<Directory "D:\projects\first">
Options FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Require all granted
</Directory>
</VirtualHost>
<VirtualHost mysecond-project.local:80>
DocumentRoot "D:\projects\second"
ServerName mysecond-project.local
ErrorLog "logs/second-error.log"
CustomLog "logs/second-access.log" common
<Directory "D:\projects\second">
Options FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Require all granted
</Directory>
</VirtualHost>
If I open mysecond-project.local on the browser, I'll be immediately redirected to myfirst-project.local
I have no idea why is it happening.
httpd -S
To determine where/how your virtualhosts were actually being loaded. If your Apache version is 2.2 or earlier you have to add this line before the VirtualHost definitions:
NameVirtualHost *:80
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.