Permalinks not working for some URLs

I am working on a tool to import from MVCForum and trying to figure out how I can make Discourse permalink from some old URLs. Some URLs worked with the discourse permalink feature but some did not (I got the “Oops! That page doesn’t exist or is private.” message for those)

The old URL can look like this:

 thread/forum-software-upgrade/?order=all#comment-e3c739ae-1b3c-494c-850c-a6cc00b81acc

For substrings truncated after the question mark, the permalink worked.
For example, permalinks worked for the following URLs:

thread/forum-software-upgrade
thread/forum-software-upgrade/
thread/forum-software-upgrade/?

But not for those:

thread/forum-software-upgrade/?order
thread/forum-software-upgrade/?order=all
thread/forum-software-upgrade/?order=all#comment-e3c739ae-1b3c-494c-850c-a6cc00b81acc

See the setting

permalink normalizations
5 Likes