This commit is contained in:
Mrx
2026-02-28 15:43:14 +08:00
parent b73de98a71
commit b8defa47ab
29 changed files with 3216 additions and 73 deletions

View File

@@ -0,0 +1,30 @@
# ========== 在服务器上替换 SEO 的 location 用这一段 ==========
#
# 步骤:
# 1. 宝塔 → 网站 → 找到 www.xingfucha.cn → 设置 → 配置文件
# 2. 在配置文件里搜索__seo__ 或 seo-templates
# 3. 删掉旧的 SEO location 块改成下面「新写法」两段seo-templates 段 + location / 里的 if+rewrite
# 4. 保存 → SSH 执行 nginx -t && nginx -s reload
#
# ---------- 新写法(用 root不依赖 alias-----------
#
# 第一段:内部 location放在 location / 之前)
location /seo-templates/ {
internal;
add_header Content-Type "text/html; charset=utf-8";
add_header X-SEOMiddleware "nginx-prerendered";
}
# 第二段:在 location / 里必须有(爬虫时重写到上面)
location / {
if ($is_crawler = 1) {
rewrite ^ /seo-templates/$seo_file break;
}
try_files $uri $uri/ /index.html;
}
# 说明root 已在 server 里设为 /www/wwwroot/www.xingfucha.cn
# 请求 /seo-templates/index.html 会读文件 .../seo-templates/index.html
# ---------- 结束 ----------