You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache Bitnami虚拟主机无法正确路由子域名问题求助

问题排查与解决步骤

1. 清理重复的虚拟主机配置

你同时在两个文件里配置了newsubdomain.domain.com的虚拟主机,这会导致Apache匹配逻辑混乱:

  • 删除/opt/bitnami/apache/conf/vhosts/test-vhost.conf,或者注释掉其中关于newsubdomain.domain.com的配置(该文件里的127.0.0.1仅用于本地访问,不适合对外域名)。
  • 简化httpd-vhosts.conf里的新子域名配置,去掉重复的ServerAlias,同时把日志路径改成绝对路径避免权限问题:
<VirtualHost *:80>
    ServerName newsubdomain.domain.com
    DocumentRoot /home/bitnami/test
    <Directory /home/bitnami/test/>
            Options -Indexes
            AllowOverride All
            Require all granted
    </Directory>
    ErrorLog "/opt/bitnami/apache/logs/test-error_log"
    CustomLog "/opt/bitnami/apache/logs/test-access_log" common
</VirtualHost>

2. 确认Apache加载了虚拟主机配置

打开/opt/bitnami/apache/conf/httpd.conf,确保存在以下配置(没有就手动添加):

Include conf/httpd-vhosts.conf

3. 验证域名解析

在本地终端执行ping newsubdomain.domain.com,确认返回的IP和你的服务器IP一致。如果不符,去域名服务商后台检查A/CNAME记录,确保解析指向正确服务器,等待10-30分钟让DNS缓存生效。

4. 排查重定向来源

  • 用浏览器无痕模式访问新子域名,避免本地缓存干扰。
  • 在服务器上执行curl -v newsubdomain.domain.com,查看请求过程里的重定向信息,确认是Apache配置还是.htaccess导致的跳转。

5. 检查重定向规则

  • 查看老子域名根目录/opt/bitnami/apache/htdocs/.htaccess,确认没有强制跳转到老子域名的规则。
  • 检查新子域名目录/home/bitnami/test/.htaccess,确保无错误重定向配置。

6. 重启Apache生效配置

执行Bitnami官方重启命令:

sudo /opt/bitnami/ctlscript.sh restart apache

内容的提问来源于stack exchange,提问作者Dani Márquez BiG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 20:12:33