问题
I use Xampp and I want test.localhost to go to 127.0.0.1:81.
In httpd.conf I wrote:
Listen 127.0.0.1:81
NameVirtualHost 127.0.0.1:81
<VirtualHost 127.0.0.1:81>
ServerName test.localhost
DocumentRoot "d:\_projects\projectx"
DirectoryIndex index.php
</VirtualHost>
and to windows\system32\drivers\etc\hosts I added:
127.0.0.1 test.localhost
But http://test.localhost now brings me to 127.0.0.1:80.
How do I make it go to 127.0.0.1:81?
回答1:
As far as your browser is concerned, http://test.localhost is http://test.localhost:80.
What you want is an Apache redirect...
<VirtualHost 127.0.0.1:80>
ServerName test.localhost
Redirect / http://test.localhost:81
</VirtualHost>
回答2:
Or just go http://test.localhost:81 on your browser instead of using Redirect.
来源:https://stackoverflow.com/questions/7823073/apache-virtualhost-how-to-servername-a-port-different-from-80