Files
xfc_webview_V2/server/nginx-seo-location-替换片段.conf
2026-02-28 15:43:14 +08:00

31 lines
1.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ========== 在服务器上替换 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
# ---------- 结束 ----------