Permalink normalization regex problem

I’m trying to fix permalinks from URLs like this:

http://hostname/forum/category-slug-not-in-the-database/ID-slug-not-matching-title.html

My plan is to create permalinks like

 forum/ID --> topic id

and then a permalink normalization that strips the category slug and the topic slug like this:

/forum\/.*\/([0-9]+).*/forum\/\1

If I fix the URL by hand, it works, but I can’t get the permalink normalization to work. I’ve checked my regex at http://regexr.com/, but I’m still not getting it to work. Am I missing something obvious?

1 Like

You don’t need to \ the / in the replacement string.

Edit:

/forum\/.\/([0-9]+?)./forum\/\1

Added ? to fix topics with a title that starts with a number.

3 Likes