nginxurl-rewritingmybb

nginx rewrite mybb to wbb


we are in the middle of a migration from mybb to wbb and therefore I would need to rewrite the following URLs using nginx:

1st rule

from: somedomain/forum-123.html => to: somedomain/board/123/

2nd rule

from: somedomain/thread-1234-post-12345.html => to: somedomain/thread/1234/?postID=12345

Can someone help me with those rewrite rules?

Thanks and many regards

PS: sorry for the bad syntax. but i don't have any reputation and wasnt able to post some "example" links


Solution

  • location ~ ^/forum-([0-9]+)\.html {
        return 301 /board/$1/;
    }
    
    location ~ ^/thread-([0-9]+)-post-([0-9]+)\.html {
        return 301 /thread/$1/?postID=$2;
    }
    

    This will send permanent redirect replies, which means browsers should assume that the content has moved for good and that they may update bookmarks and such automatically.