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

CentOS Apache内部链接指向指定文件夹配置问题求助

问题解决方法

你的配置里有两个关键问题导致跳转异常:

  1. ServerName格式错误:ServerName字段不需要带http://前缀,直接写域名即可。
  2. 多余的Redirect指令:你已经把DocumentRoot指向了/var/www/html/vgr/,这时候再添加Redirect会干扰正常的目录映射,完全没必要保留这条指令。

修正后的VirtualHost配置如下:

<VirtualHost *:80>
    ServerName vgr.intranet
    DocumentRoot /var/www/html/vgr/

    # 可选:添加Directory块确保目录权限正常
    <Directory /var/www/html/vgr/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

修改后执行以下步骤生效:

  • 重启Apache服务:sudo systemctl restart apache2(Debian/Ubuntu系)或sudo systemctl restart httpd(RHEL/CentOS系)
  • 清除浏览器缓存,避免旧跳转规则影响测试

这样访问vgr.intranet时,Apache会直接加载/var/www/html/vgr/下的内容,无需额外跳转。

内容的提问来源于stack exchange,提问作者Blind

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 04:39:50