如何在apache中加载subdomain like子目录?

时间:2016-12-25 10:49:18

标签: php apache wampserver

我正在研究一个连接到用PHP编写的web api的android应用程序。 我在httpd-vhost conf文件中通过此配置设置了子域:

<VirtualHost *:8080>
DocumentRoot "c:/wamp/www/Clinic"
ServerAlias Clinic.localhost
ServerName Clinic.localhost
    <Directory "c:/wamp/www/Clinic">
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

当我连接到这样的设置时,此设置有效:

  

http://clinic.localhost:8080

但现在我想从Android设备连接到这个API。没有DNS服务器,我现在必须通过服务器IP连接到此API,当我尝试通过此URL连接时:

  

http://192.168.1.102:8080/clinic

我收到404错误,我的系统无法解析主机。

1 个答案:

答案 0 :(得分:0)

我找到了原因。在我的httpd-vhost配置文件中,我的root用户没有虚拟主机,因为这个apache无法识别主机根文件夹。我将此配置添加到我的配置文件中,并且每件事都可以。

<VirtualHost *:8080>
    DocumentRoot "c:/wamp/www"
    ServerAlias localhost
    ServerName localhost
</VirtualHost>
相关问题