User pfaffman is trying to improve permalink redirects on the vBulletin importer. The issue is with a regular expression (regex) that isn’t working as expected. The goal is to redirect URLs like http://somesite/forums/f38/slug-blah-blah-blue-11769.html to oldlinks/topics/thread-11769.
The original regex was: /forums\/f[0-9]+\/.+-([0-9])+\.html.*/oldlinks\/topics\/thread-\1. However, it wasn’t working.
user elijah suggested that the trailing slash might be the issue, and pfaffman confirmed that the regex should have a closing /. However, adding the closing / didn’t resolve the issue.
Mittineague questioned whether the URL format ".html" was necessary and suggested removing the .* at the end of the regex.
After further investigation, pfaffman realized that the issue was with the replacement string, not the regex. The correct regex is: /forums\/f[0-9]+\/.+-([0-9]+)\.html/oldlinks\/topics\/thread-\1. The key change was adding a + after [0-9] to match one or more digits.
I’m trying to improve the permalink redirects on the vbulletin importer. Vbulletin can have any of several URL formats. My solution is to create generic permalinks which will then be handled by permalink normalizations. Like this:
Thanks, @elijah. Are you saying I’m missing one, or that I’ve got an extra? In either case, it looks OK, right? I added an image of the normalizations since there’s no way to copy them.
I’m good with REs, but that means I know there are a maze of similar looking implementations all with slightly different syntax. Your RE looks to be / delimited, but has no closing /:
I can’t help but wonder, do you actually have URLs that have “.html” towards the end, and if you do, how often are they followed by zero or more nothing, anything, everything characters?
I meant after the replacement string. I have a / at the end of my RE (right?), but not the end of the replacement.
I don’t know. Perhaps not. In other systems I’ve seen various cruft after the URL (as the example replacement suggests). I’m probably safe removing that last .* to be sure.