我刚刚使用 WHM 设置了一个 VPS。我设置了帐户,并安装了 SSL 证书。使用 HTTPS 连接一切都运行良好,但每当我尝试通过 vanilla HTTP 加载任何内容时,我都会收到 404 错误。
我查看了生成的 VirtualHost 设置,端口 80 和 443 共享同一个文档根目录。这只发生在配置了 SSL 证书的子域 (secure.example.com) 上。通过常规域 (example.com) 提供 HTTP 服务可以正常工作。
我遗漏了什么?谢谢。
更新:
这是我的 vhost 配置。
示例.com
<VirtualHost server.ip.address:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /home/username/public_html
ServerAdmin [email protected]
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/example.com combined
CustomLog /usr/local/apache/domlogs/example.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User username # Needed for Cpanel::ApacheConf
UserDir disabled
UserDir enabled username
<IfModule mod_suphp.c>
suPHP_UserGroup username username
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup username username
</IfModule>
ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/username/example.com/*.conf"
</VirtualHost>
secure.example.com
<VirtualHost server.ip.address:80>
ServerName secure.example.com
ServerAlias www.secure.example.com
DocumentRoot /home/username/public_html/secure
ServerAdmin [email protected]
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/secure.example.com combined
CustomLog /usr/local/apache/domlogs/secure.example.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User username # Needed for Cpanel::ApacheConf
UserDir disabled
UserDir enabled username
<IfModule mod_suphp.c>
suPHP_UserGroup username username
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup username username
</IfModule>
ScriptAlias /cgi-bin/ /home/username/public_html/secure/cgi-bin/
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/username/secure.example.com/*.conf"
</VirtualHost>
secure.example.com:443
<VirtualHost server.ip.address:443>
ServerName secure.example.com
ServerAlias www.secure.example.com
DocumentRoot /home/username/public_html/secure
ServerAdmin [email protected]
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/secure.example.com combined
CustomLog /usr/local/apache/domlogs/secure.example.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User username # Needed for Cpanel::ApacheConf
UserDir disabled
UserDir enabled username
<IfModule mod_suphp.c>
suPHP_UserGroup username username
</IfModule>
<IfModule !mod_disable_suexec.c>
SuexecUserGroup username username
</IfModule>
ScriptAlias /cgi-bin/ /home/username/public_html/secure/cgi-bin/
SSLEngine on
SSLCertificateFile /etc/ssl/certs/secure.example.com.crt
SSLCertificateKeyFile /etc/ssl/private/secure.example.com.key
CustomLog /usr/local/apache/domlogs/secure.example.com-ssl_log combined
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
<Directory "/home/username/public_html/secure/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/ssl/2/username/secure.example.com/*.conf"
</VirtualHost>
答案1
您确定这些 vhost 配置正在加载吗?(也就是说,它们是否包含在 apache2.conf 中)?如果未加载 secure.example.com 配置,则对 secure.example.com 的 80 端口请求可能会由 example.com 处理,因此会得到 404 错误,因为文件 URI 是错误的。(要检查这个概念,请尝试添加到secure/
请求 URL 中,看看它们是否有效。)