2017-06-21 116 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

謝謝喲你非常喜歡米格爾,你的幫助太棒了。 –