【问题标题】:Apache virtual host subdomains not workingApache 虚拟主机子域不起作用
【发布时间】:2022-01-12 13:34:07
【问题描述】:

我正在使用 httpd-vhosts.conf、apache 版本 2.4.51 和 Windows Server。 子域不工作。

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

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

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

谢谢!!!

【问题讨论】:

    标签: apache virtualhost


    【解决方案1】:

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

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

    【讨论】:

    • o.O 非常感谢!我添加了 TXT dns 记录而不是 A 记录,这就是问题所在。在检查了您的评论并创建了一条 A 记录后,它起作用了!非常非常!我认为您只能使用虚拟主机管理子域,但您也必须将其设置为 dns。
    猜你喜欢
    • 2018-05-09
    • 2015-05-27
    • 1970-01-01
    • 2015-10-23
    • 1970-01-01
    • 2019-04-19
    • 2015-02-22
    • 2014-12-28
    • 2015-02-24
    相关资源
    最近更新 更多