Forum Discussion
TenYr_214337
Nimbostratus
Aug 05, 2015iRules Redirect Site to Site
Question: I have created this Redirect. Can anyone tell me why this is not working?
when HTTP_REQUEST {
set host_lowcase [string tolower [HTTP::header "Host"]]
switch -glob $host_lowcase...
Stanislas_Piro2
Cumulonimbus
Aug 06, 2015Hi, little change of the irule with:
- it's better to convert HTTP:host to lowercase before string evaluation
.
HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"mysite.mynet.com" {
HTTP::respond 302 location "https://mynew.mynet.com[HTTP::uri]"
}
"mysite2.mynet.com" {
HTTP::respond 302 location "https://mynew2.mynet.com[HTTP::uri]"
} default {
return
apply no redirect
}
}
}
What was wrong in the first iRule:
- if you evaluate a lowercase string with uppercase string... it will never match 🙂
- the hostname never start with "\"
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