Apache VirtualHost: How to ServerName a port different from 80

為{幸葍}努か 提交于 2019-12-08 04:28:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!