WAMP 服务器上的子域无法正常工作

Subdomain on WAMP Server Not Working

我的 WAMP 服务器配置有一个重要问题。我试过许多网站上列出的许多配置都无济于事。我正在尝试使目录 /forums 可以通过 https://forums.centmc.tk. However, upon travelling to https://forums.centmc.tk, it almost immediately says "forums.centmc.tk's server IP address could not be found." https://centmc.tk works fine, and so does the 301 redirect from https://centmc.tk/forums to https://forums.centmc.tk 访问。我只是不明白为什么子域不起作用。

我知道这是我的 httpd-vhosts.conf 文件的问题,所以这是:

# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "c:/wamp64/www"
<Directory "c:/wamp64/www/">
  Options +Indexes +Includes +FollowSymLinks +MultiViews
  AllowOverride All
  Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:443>
DocumentRoot   c:/wamp64/www
ServerName     centmc.tk
SSLEngine      on
SSLCertificateFile c:/wamp64/bin/apache/apache2.4.27/conf/centmc.tk.crt
SSLCertificateKeyFile c:/wamp64/bin/apache/apache2.4.27/conf/centmc.tk.key
Redirect 301 /forums https://forums.centmc.tk
Redirect 301 /forum https://forums.centmc.tk
<Directory "c:/wamp64/www/">
  Options +Indexes +Includes +FollowSymLinks +MultiViews
  AllowOverride All
  Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:443>
ServerName centmc.tk
ServerAlias forums.centmc.tk
VirtualDocumentRoot "c:/wamp/www/forums"
ErrorLog "c:/wamp64/bin/apache/apache2.4.27/logs/errors.log"
<Directory "c:/wamp/www/forums">
  Options +Indexes +Includes +FollowSymLinks +MultiViews
  AllowOverride All
  Require all granted
</Directory>
</VirtualHost>

提前感谢您的帮助!抱歉,顶部的文本块比较大。

卢卡斯。

听起来像是 DNS 问题。如果您是网络上的 运行 DNS 服务器,则需要为 "forums" 子域添加 "A" 记录。像这样:

; example.com [448369]
$TTL 86400
@   IN  SOA ns1.linode.com. admin.example.com. 2013062147 14400 14400 1209600 86400
@           MX  10  mail.example.com.
@           A   ###.###.###.###
mail        A   ###.###.###.###
www         A   <put your server IP here>
forums      A   <put your forums server IP here>

如果您正在使用 public DNS 服务器(如 8.8.8.8、4.4.4.4,或者只是您的默认 ISP 的 DNS 服务器...您需要将 CNAME 记录添加到您的域的任何位置名称已注册。(例如 GoDaddy)。这是 link 如何在 GoDaddy 上注册:https://www.godaddy.com/help/add-a-subdomain-that-points-to-an-ip-address-4080

希望对您有所帮助。