Forum Discussion
dean_02_164511
Nimbostratus
Mar 09, 2016Redirect match country and string not in url
I'm using a datagroup like below and the Irule like below. I'm trying to add a statement where if it matches the country australia and doesn't have pid=search in the url, redirect to x else redirect ...
Kai_Wilke
MVP
Mar 09, 2016Hi Dean,
you may take a look to the two iRules below. They are outlining two different coding styles to achive what you've asked for...
"AND NOT with NE" Syntax
when CLIENT_ACCEPTED {
if { [set country [whereis [IP::client_addr]]] eq "" } then {
set country "empty"
}
}
when HTTP_REQUEST {
set redir [class match -value -- $country contains country-redirect]
if { ( $country eq "AU" ) and
( $redir ne "" ) and
( [URI::query [HTTP::uri] "pid"] ne "search" ) } then {
Do whatever you want...
} elseif { $redir ne "" } then {
HTTP::redirect $redir
} else {
HTTP::redirect "http://default.example.com/"
}
}
"AND with EQ" Syntax
when CLIENT_ACCEPTED {
if { [set country [whereis [IP::client_addr]]] eq "" } then {
set country "empty"
}
}
when HTTP_REQUEST {
set redir [class match -value -- $country contains country-redirect]
if { ( $country eq "AU" ) and
( $redir ne "" ) and not
( [URI::query [HTTP::uri] "pid"] eq "search" ) } then {
Do whatever you want...
} elseif { $redir ne "" } then {
HTTP::redirect $redir
} else {
HTTP::redirect "http://default.example.com/"
}
}
Cheers, Kai
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