• Resolved Jason Judge

    (@judgej)


    I cannot find this in the documentation, so am asking here.

    The docs say there is “full regular expression” support, and it does appear there is for URL matching. However, if you want to use a part of the matching expressing in the redirect destination, it is not clear whether that is possible.

    For example, if matching:

    /articles/123

    I wanted to take the visitor to:

    /features/123

    and do so in a generic way for all articles, can that be done? In plain PHP (preg_replace) the RE would be:

    #/articles/[0-9]+#

    and the destination would then be:

    /features/$1

    That doesn’t work in this plugin, but is there a form that does?

    • This topic was modified 8 years, 1 month ago by Jason Judge.
Viewing 1 replies (of 1 total)
  • Thread Starter Jason Judge

    (@judgej)

    I looked through the code and found the preg_replace() that looked like this was very much supported. So I looked again at what I was doing, and realised my syntax was wrong.

    So here is a matching RE (the Source URL):

    /articles/([0-9]+)

    and the Destination URL is:

    /features/$1

    Note the brackets in the matching RE that maps its sub-expression to $1. Any kind of expression could go in there, such as a simple (.+) to match any characters at all.

    I’ll close this support ticket as it all seems to be working nicely. Some examples in the docs may help people a lot though.

    • This reply was modified 8 years, 1 month ago by Jason Judge.
    • This reply was modified 8 years, 1 month ago by Jason Judge.
Viewing 1 replies (of 1 total)
  • The topic ‘Supporting Regular Expression (RE) Replacement Parameters?’ is closed to new replies.