Forum Discussion
iRule re-direct & Exclusions
Hi all,
Im hoping some guidance on creation of an iRule to redirect some traffic, as follows:
If URL request contains http://www.domain1.com/ redirect requests to http://domain2.domain.com/economic-research-unit.
But what i also require is some exclusions from the general redirect.
Example:
http://www.domain1.com/researcharchive.asp?UK%20Economy%20Watch http://www.domain1.com/researcharchive.asp?UK%20Economy%20Presentations
The above URLs will be excluded from the irule redirect. Is this even possible with iRule?
Thanks in advance guys. Most helpful forum in town :)
Hi Superd,
always remember: "iRule can do!" ;-)
how many exception are you planing to have? Just a few, some more or really a lot of? Depending on the number the best practise TCL code would look somewhat different...
Cheers, Kai
- Stanislas_Piro2Cumulonimbus
Hi super,
- irules work with host, uri, path, query, parameters... not URL...
- your 2 exceptions are one as this is the same path... only the query string is different and I'm not sure you want to check every parameter values.
this is an irule that can help you to begin:
when HTTP_REQUEST { if { [HTTP::host] equals "domain1.com"} { switch -glob [string tolower [HTTP::path]] { "/researcharchive.asp" {return} default {HTTP::redirect http://domain2.domain.com/economic-research-unit} } } }
Hi Superd,
use this technique if you want to exclude just "some" URIs (not more than 10)
when HTTP_REQUEST { if { [HTTP::host] eq "www.domain.de" } then { set low_uri [string tolower [HTTP::uri]] if { ( $low_uri equals "/researcharchive.asp?uk%20economy%20watch" ) or ( $low_uri equals "/researcharchive.asp?uk%20economy%20presentations" ) or ( $low_uri contains "/researcharchive2.asp" ) } then { Do nothing } else { HTTP::redirect "http://domain2.domain.com/economic-research-unit" } } }
Use this technique if you want to exclude a bunch of URIs (more than 10 but not more than 50)
when HTTP_REQUEST { if { [HTTP::host] eq "www.domain.de" } then { switch -glob -- [string tolower [HTTP::uri]] "/somedummypath/" - \ "/researcharchive.asp?uk%20economy%20watch" - \ "/researcharchive.asp?uk%20economy%20watch2" - \ "/researcharchive.asp?uk%20economy%20watch3" - \ "/researcharchive.asp?uk%20economy%20watch4" - \ "/researcharchive.asp?uk%20economy%20presentations" - \ "/researcharchive.asp?uk%20economy%20summary*" - \ "/researcharchive2.asp?*" - \ "/some_wildcard_path/*" - \ "/some_explicit_path/" - \ "/favicon.ico" { Do nothing } default { HTTP::redirect "http://domain2.domain.com/economic-research-unit" } } }
Use this technique if you want to exclude a lot of URIs (more than 50)
Remark: You have to configure the "EXEMPTED_URIs" in a seperated Datagroup. See https://support.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/bigip-system-irules-concepts-11-6-0/6.html for further information.
when HTTP_REQUEST { if { [HTTP::host] eq "www.domain.de" } then { if { [class match [string tolower [HTTP::uri]] starts_with EXEMPTED_URIs ] } then { Do nothing } else { HTTP::redirect "http://domain2.domain.com/economic-research-unit" } } }
Cheers, Kai
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