Forum Discussion
SteveEason
Dec 11, 2020Cirrus
iRule to reroute to new site while evaluating variables
We have to route a website to a new website while maintaining the variables in the URL, and then append a new variable. I have that iRule working. However, there is a complication. There are 3 variab...
- Dec 11, 2020
Hi SteveEason,
string tolower: Returns lowercase value.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains "code1"} { HTTP::redirect "https://www.newwebsite.com/Code1&fcRedirect=true" } elseif { [string tolower [HTTP::host]] starts_with "code2"} { HTTP::redirect "https://www.newwebsite.com/Code2&fcRedirect=true" } elseif { [string tolower [HTTP::host]] starts_with "code3"} { HTTP::redirect "https://www.newwebsite.com/Code3&fcRedirect=true" } else { HTTP::redirect "https://www.newwebsite.com[HTTP::uri]&fcRedirect=true" } }
switch version:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { "*code1*" { HTTP::redirect "https://www.newwebsite.com/Code1&fcRedirect=true" } "*code2*" { HTTP::redirect "https://www.newwebsite.com/Code2&fcRedirect=true" } "*code3*" { HTTP::redirect "https://www.newwebsite.com/Code3&fcRedirect=true" } default { HTTP::redirect "https://www.newwebsite.com[HTTP::uri]&fcRedirect=true" } } }
If codeX tags are contained in uri instead of host, you should use [HTTP::uri] instead of [HTTP::host].
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "*code1*" { HTTP::redirect "https://www.newwebsite.com/Code1&fcRedirect=true" } "*code2*" { HTTP::redirect "https://www.newwebsite.com/Code2&fcRedirect=true" } "*code3*" { HTTP::redirect "https://www.newwebsite.com/Code3&fcRedirect=true" } default { HTTP::redirect "https://www.newwebsite.com[HTTP::uri]&fcRedirect=true" } } }
Dec 11, 2020
Hi SteveEason,
string tolower: Returns lowercase value.
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "code1"} {
HTTP::redirect "https://www.newwebsite.com/Code1&fcRedirect=true"
}
elseif { [string tolower [HTTP::host]] starts_with "code2"} {
HTTP::redirect "https://www.newwebsite.com/Code2&fcRedirect=true"
}
elseif { [string tolower [HTTP::host]] starts_with "code3"} {
HTTP::redirect "https://www.newwebsite.com/Code3&fcRedirect=true"
}
else {
HTTP::redirect "https://www.newwebsite.com[HTTP::uri]&fcRedirect=true"
}
}
switch version:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"*code1*" { HTTP::redirect "https://www.newwebsite.com/Code1&fcRedirect=true" }
"*code2*" { HTTP::redirect "https://www.newwebsite.com/Code2&fcRedirect=true" }
"*code3*" { HTTP::redirect "https://www.newwebsite.com/Code3&fcRedirect=true" }
default { HTTP::redirect "https://www.newwebsite.com[HTTP::uri]&fcRedirect=true" }
}
}
If codeX tags are contained in uri instead of host, you should use [HTTP::uri] instead of [HTTP::host].
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"*code1*" { HTTP::redirect "https://www.newwebsite.com/Code1&fcRedirect=true" }
"*code2*" { HTTP::redirect "https://www.newwebsite.com/Code2&fcRedirect=true" }
"*code3*" { HTTP::redirect "https://www.newwebsite.com/Code3&fcRedirect=true" }
default { HTTP::redirect "https://www.newwebsite.com[HTTP::uri]&fcRedirect=true" }
}
}
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