Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter rjakactual

    (@rjakactual)

    Answering my own question here. This plugin is *FANTASTIC*.

    The solution for me was not Pass-through, just a simple redirect with regular expressions enabled:

    Source URL: /receipt/(.*)/
    
    Target URL: https://app.mysite.com/mypath/$1/

    Thanks VERY much for this plugin, John!!! Fantastic work!!!

    • This reply was modified 7 years, 4 months ago by rjakactual.

    For reference, the forward slash is a valid “delimiter” for PHP regex. So surrounding a regex in slashes could have an undesired effect. For example:

    I believe your intent is that /receipt/(.*)/ should imply:
    – the query starts with a slash
    – it’s followed by the word receipt
    – that’s followed by another slash
    – anything follows that
    – and it’s trailed by a last slash

    But with slashes as the delimiter it could be interpreted simply as receipt/(.*). That means:
    – somewhere in the query will be the word receipt
    – that’s followed by a slash
    – anything follows that
    – there is no requirement for a leading or trailing slash.

    So your source will match ‘domain.tld/anythingherereceipt/foo’.
    To ensure that only catches ‘receipt’ on the front, use ‘^\/receipt/(.*)$’.
    That also eliminates the need for a slash on the back end. Slashes are often left off the back of a URL but your source requires it. That would also require removing the trailing slash from the target, or else it could get a trailing ‘\\’.

    I’m just suggesting that while your regex does work for the test cases you’ve exposed it to so far, it will also redirect requests that it should not. Being explicit about the requirement helps to ensure you only get what you really want.

    HTH

    • This reply was modified 7 years, 4 months ago by Tony G.
    • This reply was modified 7 years, 4 months ago by Tony G. Reason: Had to fix backticks intercepted by the site

    This site is deleting anything with more than the simplest backticks so I need to stop using them. I hope this doesn’t appear to others as multiple posts.

    For reference, the forward slash is a valid “delimiter” for PHP regex. So surrounding a regex in slashes could have an undesired effect. For example:

    I believe your intent is that ‘/receipt/(.*)/’ should imply:
    – the query starts with a slash
    – it’s followed by the word receipt
    – that’s followed by another slash
    – anything follows that
    – and it’s trailed by a last slash

    But with slashes as the delimiter it could be interpreted simply as ‘receipt/(.*)’. That means:
    – somewhere in the query will be the word receipt
    – that’s followed by a slash
    – anything follows that
    – there is no requirement for a leading or trailing slash.

    So your source will match ‘domain.tld/anythingherereceipt/foo’.
    To ensure that only catches ‘receipt’ on the front, use ‘^\/receipt/(.*)$’.
    That also eliminates the need for a slash on the back end. Slashes are often left off the back of a URL but your source requires it. That would also require removing the trailing slash from the target, or else it could get a trailing ‘\\’.

    I’m just suggesting that while your regex does work for the test cases you’ve exposed it to so far, it will also redirect requests that it should not. Being explicit about the requirement helps to ensure you only get what you really want.

    HTH

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Documentation For Pass-through Redirects’ is closed to new replies.