Regex NGINX为站点移动而重写

Regex NGINX为站点移动而重写,regex,url,nginx,url-rewriting,Regex,Url,Nginx,Url Rewriting,我有一个问题,我们需要将我们的网站移动到另一个软件 我们有以下URL设置: Downloads / Resources Original: https://www.website.com/downloads.php?do=file&id=47 New: https://www.website.com/resources/flight-update-red.47/ Forum Original: https://www.website.com/gen-chat-213/ New: h

我有一个问题,我们需要将我们的网站移动到另一个软件

我们有以下URL设置:

Downloads / Resources
Original:
https://www.website.com/downloads.php?do=file&id=47

New:
https://www.website.com/resources/flight-update-red.47/

Forum
Original:
https://www.website.com/gen-chat-213/

New:
https://www.website.com/forums/gen-chat.213/

Thread
Original:
https://www.website.com/gen-chat-213/8281-connect-probs.html

New:
https://www.website.com/threads/connect-probs.8281/
我在论坛部分尝试了以下方法:

rewrite ^/(.*)-$/ /forums/$1.$2/ last;
但是运气不好有人能帮忙吗


谢谢

试试这个。这是基于您的示例的

   location / {
      # Downloads / Resources
      if ($args ~* "id=(\d+)") {
        set $id $1;
        set $args '';
        rewrite ^/downloads\.php(.*)$ /resources/flight-update-red.$id/ permanent;
      }

      # Forum
      rewrite ^/([a-z-]+)-(\d+)/$ /forums/$1.$2/ permanent;

      # Thread
      rewrite ^/[a-z-]+-\d+\/(\d+)-(.*)\.html$ /threads/$2.$1/ permanent;
   }

MISAKE抱歉-你能帮我处理这些来自THREADS:
https://www.website.com/gen-chat-213/8281-connect-probs-2.html https://www.website.com/gen-chat-213/8281-connect-probs-3.html https://www.website.com/gen-chat-213/8281-connect-probs-4.html 
至<代码>https://www.website.com/threads/connect-probs.8281/page-2 https://www.website.com/threads/connect-probs.8281/page-3 https://www.website.com/threads/connect-probs.8281/page-4 非常感谢米格尔,你的帮助太棒了。试试这个
重写^/[a-z-]+-\d+\/(\d+)([a-z-]+)-(\d+)-.html$/threads/$2.$1/页-$3/永久这对Maguel有效!非常感谢。“我必须在线程重写之前将页面重写,否则将无法工作。@MarkDavis创建一个新问题并将链接发送给我。”