Permalink normalization regex problem


(Jay Pfaffman) #1

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?


(Jay Pfaffman) #2

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.