docs: 部署节更正为 Apache + 补充 SPA .htaccess 回退说明

实际对外服务是 Apache 2.4(非 nginx),DocumentRoot /var/www/html。
history 模式下直接访问 /mobile-game 会 404,已用站点根 .htaccess 回退
(该文件不纳入本项目仓库,仅文档说明)。
This commit is contained in:
Zikai
2026-07-12 15:24:34 +00:00
parent e8dee338ed
commit 0adb320a47

View File

@@ -164,9 +164,30 @@ npm run preview # 本地预览构建后的产物
## 部署
构建产物直接落在站点根 `/root/html`,由 Web 服务器(如 nginx以 `/root/html` 为根提供静态服务即可
注意:当前主机上 nginx 默认 root 为 `/var/www/html`(与 `/root/html` 内容同步);
若需以 `/root/html` 为根对外服务,请调整 nginx 的 `root` 指令并启用 nginx。
构建产物直接落在站点根 `/root/html`,由 Web 服务器以该目录为根提供静态服务。
本机实际情况:**Apache 2.4**(非 nginx对外服务 `https://zikai.wang`
`DocumentRoot /var/www/html``/var/www/html` 与 `/root/html` 内容同步),
`mod_rewrite` 已启用且 `AllowOverride All`。
### ★ SPA 回退history 模式必需)
本站用 Vue Router **history 模式**,客户端路由如 `/mobile-game` 并非真实文件。
直接访问或刷新此类 URL 时,服务器会找不到文件而 404。已在 `/root/html/.htaccess`
配置回退(该文件在 `/var/www/html` 同步可见):
```apache
RewriteEngine On
# 真实文件/目录直接放行
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# 其余路由回退到 index.html由前端路由处理
RewriteRule ^ index.html [L]
```
> 该 `.htaccess` 是站点根的部署配置,不属于本项目源码,故未纳入 `mainPage` git 仓库。
> 若重新部署/迁移服务器,需在站点根放置此文件(并确保 Apache 允许 `.htaccess` 覆盖)。
主页引用的 `/448/...`、`/449/...` 资源必须能从站点根访问到448/449 目录本就在 `/root/html` 下)。
---