2017-06-21 112 views
1

我遇到问题,我们需要将我们的网站移至其他软件。NGINX重写网站移动

我们有以下的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; 

,但没有运气能有人帮,

谢谢

回答

1

试试这个。这是基于你的例子。

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; 
    } 
+0

嗨Migeul,这些工作很棒! –

+0

MISAKE对不起 - 你能帮助我,这些也 页面,从主题: '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 ' –

+0

谢谢哟你非常喜欢米格尔,你的帮助太棒了。 –