Forum Discussion
Redirect some users if they hit a certain uri
Hi,
I need to redirect certain users (client IP's) when they land to a certain page behind my virtual page.
Basically the below and also checking if the uri equals a page:
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals my_ip_dg] } {
HTTP::redirect "http://10.200.200.200"
}
}
However, my efforts have been in vain. What would I need to do to get this work?
3 Replies
- Vijay_E
Cirrus
You would have to explain what went wrong with your efforts to better assist you. I think this iRule should work:
when HTTP_REQUEST { if { ([class match [IP::client_addr] eq my_ip_dg]) and ([HTTP::uri] eq "/abcd") } { HTTP::redirect "http://10.200.200.200/" } } - TayF5un
Nimbostratus
You can also use client accepted condition.
Hi Gurdip,
unless you're using HTTP/1.0 without keep-alive sessions, then it would be more effective to evaluate the Client IP during the CLIENT_ACCEPTED event (triggered once at the beginning of each TCP session), store the
results into a[class match]
and the use the stored results on each single HTTP_REQUEST.$variablewhen CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals my_ip_dg] } { set is_redirect 1 } else { set is_redirect 0 } } when HTTP_REQUEST { if { $is_redirect } then { if { [string tolower [HTTP::path]] equals "/somepath" } then { HTTP::redirect "http://10.200.200.200" } } }Note: Feel free to combinate the
andif $is_redirect
conditions. I've splitted them just for demonstration purposes.if HTTP::pathCheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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