Forum Discussion
iRule Query String Match and Redirect
I seem to be having difficulty finding too much on this and maybe it is as simple as it is, I am looking to perform a URI match with a few particular query strings and redirect to another website if the request is found. I have found a few articles indicating using a datagroup but this seems a bit excessive for the task I am looking at.
Example:
https://www.thedomain.com/dir1/index.html?newpath=Name1 -> https://www.newdomain.com/dir1/index.html?newpath=Name1
Is this as simple as something like:
when HTTP_REQUEST {
if { ( [string tolower [HTTP::host]] equals "www.thedomain.com"
) and ( [string tolower [HTTP::uri]] ends_with "Name1" ) } {
HTTP::redirect "http://www.newdomain.com[HTTP::uri]"
}
}
Will the query string after the "?" be picked up and carried over with [HTTP::uri]?
- D_TCirrus
Anyone on this?
- D_TCirrus
Or even simpler
When HTTP_REQUEST { if{ [HTTP::uri] contains “*?newpath=Name1" } {HTTP::redirect "https://www.newdomain.com/dir1/index.html?newpath=Name1 } }
You need to just play with F5 as many questions can be answered just by playing around. For this maybe see:
https://clouddocs.f5.com/api/irules/HTTP__query.html
https://clouddocs.f5.com/api/irules/URI__query.html
With HTTP:Respond you may use a different temporary redirect code etc.:
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com