Contents
How to redirect a regular expression to a new URL?
To do this you can create a regular expression such as /oldpage/ (.*). Note that the .* is surrounded brackets. This tells Redirection to ‘capture’ the data. The target URL would then be /newpage/$1. Here the $1 is replaced by the contents of the captured (.*). And so: A frequently occurring problem with regular expression is an infinite redirect.
Can a regex url match many URLs?
A regex URL can match many URLs. In addition to matching many URLs, a regular expression can extract information from the source URL and copy it to the target URL. A few examples may be helpful.
Is there such thing as an infinite redirect?
And so: A frequently occurring problem with regular expression is an infinite redirect. That is, you create a regex that redirects to a URL that is itself caught by the same regular expression. This is then redirected again, and again, and again until the browser stops with a ERR_TOO_MANY_REDIRECTS message (or equivalent).
Which is the target in a redirect pattern?
The redirect source is the match pattern, the target is the replacement pattern, and the requested URL is the subject. This means that only matched content will be replaced. If you do not match the whole URL then only the part you do match will be replaced, and the rest of the URL will be appended.
Do you need a variable for URL redirection?
You shouldn’t need a variable if that pattern is consistent. A simple rule would be: However, if you are on v11.4+, you really should use a local traffic policy for this as it is more performant as a built-in feature of TMOS.
Can a regex be used to redirect a path?
Regex is super powerful and we can use it to redirect all paths starting with the number 1 rather than having to write individual rules for each folder (e.g 1.0, 1.1, 1.2)
Which is an example of a regular expression?
In addition to matching many URLs, a regular expression can extract information from the source URL and copy it to the target URL. A few examples may be helpful. A redirect that has the source URL /my-url will only ever match requests for /my-url. A redirect that has the source URL /my-url/.* will match requests for: