我有一个问题,我们需要将我们的网站转移到另一个软件。
我们有以下网址设置:
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;
但是没有人可以帮忙,
谢谢
答案 0 :(得分: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;
}