Forum Discussion
Peak_10_71174
Nimbostratus
Dec 02, 2009irule redirect verification
I have the need to add an irule that will redirect various https requests to a different url. Since I'm not very familiar with all the rules regarding syntax and order of these various requests, what I am wondering is if I need to put the least specific redirects last in the sequence, or if it matters.
For example, I need the following redirects:
1. companytest.abc.com/path1 to companypath1.abc.com/test
2. companytest.abc.com/path2 to companypath2.abc.com/test
3. companytest.abc.com to company.abc.com/test
Here is the sample irule I have create in order to do this, I was wondering if someone could verify that I have placed these in the correct order to account for no.3 being the least specific of all the redirects:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "companytest.abc.com" && [HTTP::uri] eq "/path1" } {
HTTP::redirect "companypath1.abc.com/test"
if { [string tolower [HTTP::host]] eq "companytest.abc.com" && [HTTP::uri] eq "/path2" } {
HTTP::redirect "companypath2.abc.com/test"
if { [string tolower [HTTP::host]] eq "companytest.abc.com"} {
HTTP::redirect "http://company.abc.com/test"
}
}
Let me know if you need more clarification. Thanks for any help in advance.
- hoolio
Cirrostratus
You could use a switch statement or two to do this. It should save you a few evaluations of [string tolower [HTTP::host]].when HTTP_REQUEST { Check the requested host switch [string tolower [HTTP::host]] { "companytest.abc.com" { Check requested URI switch -glob [HTTP::path] { "/path1*" { HTTP::redirect "http://companypath1.abc.com/test" } "/path1*" { HTTP::redirect "http://companypath2.abc.com/test" } "/" { HTTP::redirect "http://company.abc.com/test" } default { Take some default action? } } } default { Will other host header values be used in requests to the VIP If so, take some default action? } } }
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