1

我想知道如何重写 nginx 这个 url:

旧网址:http ://www.webcheats.com.br/vbulletin/showthread.php?t=2175433

新网址:http ://www.webcheats.com.br/threads/2175433/

谢谢

4

2 回答 2

1
location = /vbulletin/showthread.php {
    return 301 /threads/$arg_t/;
}
于 2016-07-02T22:13:57.020 回答
0

如果您在 nginx 上使用 Xenforo 2,并且您之前已从 vBulletin 迁移,则 Xenforo 2 有一个插件可以处理重定向: Xenforo Redirects for vBulletin

但是这个插件是为 Apache 制作的,开箱即用,它不能与 Xenforo 2 和 nginx 的 SEO 友好 URL 功能一起正常工作。要解决该问题,您需要使用XF2 文档设置您的 nginx 配置以使用 SEO 友好的 URL 。

您需要做的最后一件事是阅读这篇文章,其中概述了问题的原因和修复方法。问题的原因是这一行:

  try_files $uri =404;

它会阻止重定向发生,因为旧的 vbulletin php 文件不存在。最后的解决方法是将块设置为如下所示:

location ~ \.php$ {
  try_files $uri /index.php?$uri&$args;
  #try_files $uri =404;
  fastcgi_pass    127.0.0.1:9000;
  fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
  include         fastcgi_params;
}
于 2019-08-27T20:38:01.433 回答