XAMPP默认不支持Subrion的.htaccess重写规则,必须启用mod_rewrite并配置AllowOverride All,否则因重写失效导致安装页卡住、/admin等路径404或500错误。

直接说结论:XAMPP 默认不支持 Subrion 的 .htaccess 重写规则,仅靠开多个端口无法让 Subrion 正常运行;必须启用 mod_rewrite 并正确配置 AllowOverride All,否则会卡在安装页或出现 404/500 错误。
为什么 Subrion 在 XAMPP 多端口下总跳转失败或报 404
Subrion 依赖 Apache 的 URL 重写(mod_rewrite)实现友好路径(如 /admin、/listing/123),而 XAMPP 默认关闭了虚拟主机目录的重写权限。即使你为 localhost:8080 和 localhost:8081 分别配了 <virtualhost></virtualhost>,只要 <directory></directory> 块里没放开 AllowOverride,.htaccess 就被无视——所有非 index.php 请求都会 404。
- 常见现象:打开
http://subrion.test/admin显示 404,但http://subrion.test/index.php/admin能进后台 - 根本原因:XAMPP 的
httpd.conf默认全局设了AllowOverride None,且httpd-vhosts.conf里未覆盖 - Subrion 安装检测页也会因重写不可用而提示 “Rewrite module is not enabled”
配置多端口 + Subrion 必须改的三处位置
不能只动 httpd-vhosts.conf。以下三处缺一不可,顺序也不能错:
- 确认
httpd.conf已加载虚拟主机配置:
找到#Include conf/extra/httpd-vhosts.conf,删掉开头的# - 确认
mod_rewrite已启用:
在httpd.conf中搜索mod_rewrite.so,确保该行未被注释(即不是#LoadModule rewrite_module modules/mod_rewrite.so) - 在
httpd-vhosts.conf每个<virtualhost></virtualhost>块内,<directory></directory>部分必须包含:AllowOverride AllRequire all granted
(注意:不要写Order Deny,Allow这类旧语法,XAMPP 5.6+ 默认用Require)
端口选择与 Subrion 实际部署示例
Subrion 推荐用域名访问(如 subrion.test),但若坚持用端口(比如调试两个不同版本),请避开 80/443/8080 这些易冲突端口,选 8082、8083 等,并确保 Windows 防火墙放行。
XAMPP 8.0.30 是一款免费、开源的跨平台 Web 服务器集成包,专为快速搭建本地 PHP 开发环境而设计。该版本核心组件包括:Apache 2.4.56、MySQL 8.0.33、PHP 8.0.30、phpMyAdmin 5.2.1 等。它支持 Windows、Linux 和 macOS 系统,可让开发者在个人电脑上轻松模拟服务器环境,无需复杂配置即可运行 WordPress、Thin
- 在
httpd.conf添加监听:Listen 8082Listen 8083 - 在
httpd-vhosts.conf添加对应块(以 8082 为例):<virtualhost> ServerName localhost DocumentRoot "C:/xampp/htdocs/subrion-v4" <directory> Options Indexes FollowSymLinks AllowOverride All Require all granted </directory></virtualhost> - Subrion 的
config.php中,$config['url']应设为http://localhost:8082/,否则后台链接仍走 80 端口
容易被忽略的 Subrion 权限与 PHP 扩展问题
即使 Apache 配置全对,Subrion 仍可能卡在安装页或上传失败——这不是端口的事,而是环境缺失:
- PHP 扩展必须启用:
gd、mbstring、xml、curl(XAMPP 默认开了前三个,curl需手动取消php.ini中;extension=curl的注释) - Windows 下 Subrion 的
cache/、uploads/目录需有写权限(右键文件夹 → 属性 → 安全 → 编辑 → 给 Users 组“修改”权限) - 若用
subrion.test域名而非端口,hosts 文件必须加127.0.0.1 subrion.test,且浏览器要清 DNS 缓存(chrome://net-internals/#dns→ Clear host cache)
端口只是路由入口,Subrion 的真实瓶颈永远在重写能力、PHP 扩展和目录权限这三块。配完多端口后第一件事,不是打开浏览器,而是运行 xampp/apache/bin/httpd.exe -t 检查配置语法,再看 Apache error.log 里有没有 mod_rewrite 相关报错——这才是最常被跳过的验证动作。










