Forum Discussion
iRules 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 { "\MySite.Mynet.com" { HTTP::redirect https://MyNew.Mynet.com[HTTP::uri] } } }
2 Replies
- Hannes_Rapp
Nimbostratus
Sorry but this iRule has too many problems to bring out anything in particular. Please modify the iRule below to meet the requirements of your environment.
HTTP_REQUEST { switch [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 } } } - Stanislas_Piro2
Cumulonimbus
Hi, 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
* 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