Apache 虚拟主机子域不工作

Apache virtual host subdomains not working

我正在使用 httpd-vhosts.conf、apache 版本 2.4.51 和 Windows 服务器。 子域无效。

httpd-vhosts.conf:

NameVirtualHost *:80

#
<VirtualHost *:80>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot "e:/wamp64/www/mydomain.com"
    <Directory  "e:/wamp64/www/mydomain.com/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

#
<VirtualHost *:80>
    ServerName subdomain.mydomain.com
    ServerAlias subdomain.mydomain.com
    DocumentRoot "e:/wamp64/www/mydomain.com/subdomain"
    <Directory  "e:/wamp64/www/mydomain.com/subdomain/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

mydomain.com 和 www.mydomain.com 都很棒!

但是如果我尝试使用:http://subdomain.mydomain.com 我总是得到错误:

Hmm. We’re having trouble finding that site.

We can’t connect to the server at subdomain.mydomain.com

If that address is correct, here are three other things you can try:

    Try again later.
    Check your network connection.
    If you are connected but behind a firewall, check that Firefox has permission to access the Web.

hosts 文件也正确:

127.0.0.1   mydomain.com
::1 mydomain.com

127.0.0.1   subdomain.mydomain.com
::1 subdomain.mydomain.com

P.S。我可以直接从主机访问它,但我不能在其他设备上访问它。

请问为什么只有子域不起作用? 我错过了什么?

谢谢!!!

这似乎更像是一个 DNS 问题,而不是服务器上的配置问题。您是否为您的子域设置了任何 DNS?也许您可以在这里找到一些帮助:

https://www.godaddy.com/help/create-a-subdomain-4080