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

Windows Server配置虚拟主机时遭遇403 Forbidden错误

解决Apache虚拟主机配置Angular应用的403错误

问题核心

你的403错误(AH01630: client denied by server configuration: C:/xampp/httpdocs),本质是Apache没有被授予访问DocumentRoot指定的C:/xampp/httpdocs目录的权限——虽然你配置了Alias目标目录的权限,但根目录的访问规则缺失,导致服务器拒绝请求。

修正后的完整配置

<VirtualHost *:80>
DocumentRoot "C:/xampp/httpdocs"
ServerName 192.168.0.32

# 修正Alias路径与实际目录名一致(原配置存在拼写不一致问题)
Alias "/rtis-fe" "C:/xampp/httpdocs/rtis-fe/dist/rtsis-fe"

# 新增DocumentRoot目录的权限配置
<Directory "C:/xampp/httpdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<Directory "C:/xampp/httpdocs/rtis-fe/dist/rtsis-fe">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

ErrorLog "logs/rtsis-error.log"
CustomLog "logs/rtsis-access.log" common

RewriteEngine On

# 仅针对/rtis-fe路径下的请求做Angular路由重写
RewriteCond %{REQUEST_URI} ^/rtis-fe/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/rtis-fe/(.*)$ /rtis-fe/index.html [L]

关键修改说明

  • 添加根目录权限配置:给C:/xampp/httpdocs目录补充规则,明确Require all granted,让Apache有权限访问根目录,解决基础的403限制。
  • 修正Alias路径拼写:原配置中Alias是/rtsis-fe,但实际目录是rtis-fe,拼写不一致会导致路径匹配失败,修正后保证Alias与实际目录名统一。
  • 优化Rewrite规则:新增RewriteCond %{REQUEST_URI} ^/rtis-fe/条件,只对Angular应用路径下的请求进行重写,避免干扰根目录下的其他内容;同时调整RewriteRule的匹配格式,确保路由重写逻辑精准。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 20:57:57