Forum Discussion
pmaubo3_109863
Nimbostratus
Jul 20, 2012Using Class for uri and url redirects
We currently have a URL where they want a uri redirect which is fine. Also, the want to use a uri to invoke a URL redirect. The issue is, if we just keep adding single irules in, it gets ugly and is ...
nitass
Employee
Jul 20, 2012what about this one?
[root@ve10:Active] config b virtual bar list
virtual bar {
snat automap
destination 172.28.19.79:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if {[class match -- [string tolower [HTTP::uri]] starts_with url_class]} {
HTTP::redirect [class match -value [string tolower [HTTP::uri]] starts_with url_class]
} else {
default pool
pool foo
}
}
}
[root@ve10:Active] config b class url_class list
class url_class {
{
"/bring_me_to_google" { "http://www.google.com" }
"/bring_me_to_yahoo" { "http://www.yahoo.com" }
}
}
[root@ve10:Active] config curl -I http://172.28.19.79/bring_me_to_google/something
HTTP/1.0 302 Found
Location: http://www.google.com
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -I http://172.28.19.79/bring_me_to_yahoo/something
HTTP/1.0 302 Found
Location: http://www.yahoo.com
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
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