1

我需要的是如下

我可以按如下方式访问本地计算机中的子域,test.localhost但我需要test.myMachineNametest.myMachineIp从我自己网络中的另一台计算机访问

我在本地 wamp 服务器中设置了子域,如下所示:

在 https-vhost.conf 中:

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www/test"
    ServerName localhost
    ServerAlias test.localhost
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

然后在 httpd.conf 中启用 vhost

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

然后在windows主机中添加如下

127.0.0.1       test.localhost
4

1 回答 1

1

我不明白你的配置。首先,如果您从另一台计算机访问 test.localhost 将无法正常工作,因为您的网站在该计算机上不存在。您必须在路由器设置中使用 IP 地址和端口转发(私有 IP:计算机本地 IP,类型:TCP,范围:80 - 80)。

https-vhost.conf 中

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

<VirtualHost *:80>
    #ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "c:/wamp/www/test"
    ServerName test.youripaddress
    ServerAlias test.youripaddress
    #ErrorLog "logs/dummy-host.example.com-error.log"
    #CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>

主机文件中:

127.0.0.1           localhost
youripaddress       test.youripaddress

问我任何问题。

于 2013-08-19T06:44:42.487 回答