Redirects in Discourse from Xenforo

AI-generated summary

In a support discussion about redirecting URLs from XenForo to Discourse, Fajfi seeks help because standard permalink redirections fail due to XenForo’s URL structure (e.g., /threads/thread-name.1234/). pfaffman suggests using Discourse’s permalink_normalization site setting. Arkshine shares a detailed guide from Neil Lalonde and bletch, explaining that regex in the normalization string must escape slashes in the pattern part but not in the replacement part, and that URLs are matched without the leading /. Examples are provided for categories, posts, and topics. Fajfi then shares working regex patterns tailored to XenForo’s format, including special handling for URLs where thread or category names contain numbers: for /threads/thread-name.1234/, use /(threads)\/(.*?)([0-9].*)?$/threads/\3; for /forums/category.1234/, use /(forums)\/(.*?)([0-9].*)?$/forums/\3. If names contain dots and numbers (e.g., thread-name.1234), use /(threads)\/(.*?\.)([0-9].*)?$/threads/\3 and similarly for forums. These regexes extract the ID and redirect to Discourse’s internal structure.

On my Xenforo board links look like this:

For category:
https://example.com/forums/category.1234/
/forums/category-name.ID/

For post:
https://example.com/threads/thread-name.1234/
/threads/thread-name.ID/

Unfortunately I guess by the amount of / and . redirection does not work after addning it in the discourse panel (/admin/customize/permalinks), is there any way to repair this and create proper redirection?

There is a permalink_normalization site setting to help with that.

Also:

Thanks!

Here’s regex for permalink normalizations for my case on XenForo:

https://example.com/threads/thread-name.1234/
/(threads)\/(.*?)([0-9].*)?$/threads/\3

https://example.com/forums/category.1234/
/(forums)\/(.*?)([0-9].*)?$/forums/\3


When there’s numbers in thread-name or category use this

/(threads)\/(.*?\.)([0-9].*)?$/threads/\3

/(forums)\/(.*?\.)([0-9].*)?$/forums/\3