I am migrating a forum from Simple Machines to Xenforo, and struggling to craft the Nginx rewrite rules. Essentially, I need to write a regex to parse the SMF urls and extract the ID of the board/forum, topic/thread, message/post, or user, then insert it into Xenforo urls. It's slightly more complex though because sometimes the IDs are passed as a parameter, and sometimes written out in the URL. SMF supports both, and I've got inbound links with both forms, so need to rewrite both. Here are the incoming URLs that I am trying to redirect: Board/forum index SMF URL structure: /forum/index.php/board,13.0.html /forum/index.php?board=13 Xenforo URL structure: /community/index.php?forums/13/ Threads/topics: SMF URL structure: /forum/index.php/topic,101.0.html /forum/index.php?topic=101.0 Xenforo URL structure: /community/index.php?threads/101/ Messages/Posts: SMF URL structure: Note: sometimes these include extra stuff after the message ID, sometimes not /forum/index.php/topic,101.msg38.html#msg38 /forum/index.php?topic=101.msg38/boardseen.html#new Xenforo URL structure: /community/index.php?posts/38/ Users: SMF URL structure--never written out, always passed as a query parameter: /forum/index.php?action=profile;u=110 Xenforo URL structure: /community/index.php?members/110 The rewrite rules should only match when the url includes `/forum/index.php` so it doesn't catch other random urls. I am pretty green with regex, any help is appreciated.