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