Forum Discussion
VFB
Cirrus
Jan 06, 2016http header and uri redirect
Hello, I'm attempting to construct an iRule that looks at a header and URI, then performs a redirect if they match. This is what I've attempted but unsuccessful. I have multiple redirects based on di...
cjunior
Nacreous
Jan 06, 2016Hi,
Maybe I did not understood well, but, as you mentioned "multiple headers", have you a list of header names or you intend to look at any of them? I think I would do like this:when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/news*" -
"/weather*" {
foreach name [list MyHeader1 MyHeader2 MyHeaderN] {
switch -glob [string tolower [HTTP::header $name]] {
"*www.yahoo.com*" {
HTTP::redirect "https://www.yahoo.com/login.aspx=0"
return
}
"*www.google.com*" {
HTTP::redirect "https://www.google.com/login.aspx=0"
return
}
}
}
}
}
}
or this for any header names:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/news*" -
"/weather*" {
foreach name [HTTP::header names] {
switch -glob [string tolower [HTTP::header $name]] {
"*www.yahoo.com*" {
HTTP::redirect "https://www.yahoo.com/login.aspx=0"
return
}
"*www.google.com*" {
HTTP::redirect "https://www.google.com/login.aspx=0"
return
}
}
}
}
}
}
I'm not sure if that was what you wanted, anyway, I hope it helps you in some way.
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
