【问题标题】:Apache VirtualHost: How to ServerName a port different from 80Apache VirtualHost:如何对不同于 80 的端口进行服务器命名
【发布时间】:2011-12-11 00:08:00
【问题描述】:

我使用 Xampp,我希望 test.localhost 转到 127.0.0.1:81

我在 httpd.conf 中写道:

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>

我添加到windows\system32\drivers\etc\hosts

127.0.0.1       test.localhost

但是http://test.localhost 现在将我带到127.0.0.1:80

如何将其转至127.0.0.1:81

【问题讨论】:

    标签: apache xampp port virtualhost httpd.conf


    【解决方案1】:

    就您的浏览器而言,http://test.localhosthttp://test.localhost:80

    你想要的是一个 Apache 重定向...

    <VirtualHost 127.0.0.1:80>
     ServerName test.localhost
    
     Redirect / http://test.localhost:81
    </VirtualHost>
    

    【讨论】:

    • 嗯,我明白了。但是我在 80 端口上已经有别的东西了——所以我实际上不想重定向。不过,你的回答在技术上是正确的,所以你应该打勾。
    【解决方案2】:

    或者直接在浏览器上转到http://test.localhost:81,而不是使用重定向。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-29
      • 2013-09-16
      • 2021-10-11
      • 2022-06-23
      • 2019-03-06
      • 2020-03-29
      • 1970-01-01
      相关资源
      最近更新 更多