[Plugin: Redirection] Issues with non capturing groups in regular expressions
-
Hello everyone,
We’re going to migrate to WordPress soon and in order to neatly redirect the current links to the new structure, we decided to use the Redirection plugin. Everything has been working fine so far in our testing environment, except for one nagging issue.
We have two particular link types
http://domain.com/item/1234/section/review.html
http://domain.com/item/1234-secondary/section/review.htmlNow, in the new site, these two links are merged, like so
So we used a regular expression that we thought would work for both links using an optional, non-capturing group for the -secondary string:
/item/([0-9]{4})(?:-secondary)?/section/review.html
which would go to
/$1
However, the problem is that the non-capturing group (-secondary) is still showing up in the final link.
So http://domain.com/item/1234/section/review.html goes to http://domain.com/1234 (as it should, no problem here)
but
http://domain.com/item/1234-secondary/section/review.html goes to http://domain.com/1234-secondary
which is wrong, because it should redirect to http://domain.com/1234 as well.
Any suggestions on how we might fix this problem would be greatly appreciated.
The topic ‘[Plugin: Redirection] Issues with non capturing groups in regular expressions’ is closed to new replies.