Forum Discussion
Anis_Bhambhani
Nimbostratus
May 21, 2020iRule to redirect to new url, but retain path in URI
I have been tasked with creating an irule to redirect a url but keep everything else in URI Tried with the below but had no luck. when HTTP_REQUEST { if { [string tolower [HTTP::host]] equ...
cjunior
Nacreous
May 21, 2020Hi,
When you " keep everything else in URI", is simple like this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "wwwabc.com" and [string tolower [HTTP::uri]] starts_with "/test/" } {
HTTP::respond 301 noserver Location "https://wwwxyz.com[HTTP::uri]"
}
}When you run "string tolower" you must compare values in lower case, and you don't need to run "string map" to replace anything else as you will keep originals.
A tip, on BIG-IP version 14 and later it is possible to set the HTTP code 301 to redirect in the LTM policy rule.
Best regards.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
