Forum Discussion
Shivesh_Rege
Nimbostratus
Jun 02, 2009irule causing loop.
Hi Friends,
I am facing an issue with an irule going into loop.Could someone help me resolving it.
when LB_FAILED {
if{[active_members [LB::server]]<1}
HTTP::redirect "http://[HTTP::host]/error/404.html"}
when HTTP_REQUEST {
if {([HTTP::path] ends_with "/doc")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/minisite")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/fslink")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/ms")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/link")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/null-request")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/exttracking.dyn")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/ms_1020109.html")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {[string tolower [HTTP::host]] contains "join" } {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/join.jsp"}
elseif {[string tolower [HTTP::host]] contains "MysteryBookOffer" } {
HTTP::redirect "http://[HTTP::host]/ecom/nm/link/home?YSID=1129&YTYP=net&YTID=BN4_02_k8_E66"}
elseif {[string tolower [HTTP::host]] contains "historybookclub" } {
HTTP::redirect "http://[HTTP::host]ecom/nm/link/home?YSID=1128&YTYP=net&YTID=BN3_02_h7_E65"}
elseif {[string tolower [HTTP::host]] starts_with "www" or "www1"} {
HTTP::c"http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}}
Thanks & Regards,
Shivesh
11 Replies
- The sections where you are checking for the host names and then redirecting to the same hostname will almost certainly cause a recursive loop.
elseif {[string tolower [HTTP::host]] contains "join" } { HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/join.jsp"} elseif {[string tolower [HTTP::host]] contains "MysteryBookOffer" } { HTTP::redirect "http://[HTTP::host]/ecom/nm/link/home?YSID=1129&YTYP=net&YTID=BN4_02_k8_E66"} elseif {[string tolower [HTTP::host]] contains "historybookclub" } { HTTP::redirect "http://[HTTP::host]ecom/nm/link/home?YSID=1128&YTYP=net&YTID=BN3_02_h7_E65"} elseif {[string tolower [HTTP::host]] starts_with "www" or "www1"} { HTTP::c"http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
It's bad practice to redirect to the same hostname that will cause a subsequent redirect. You will need to limit your comparisons down and/or add some exclusions to your logic so that the redirects you submitted will not trigger further redirects.
-Joe - Shivesh_Rege
Nimbostratus
Thanks Joe
I resolved it by using exact expression along with http:uri"/"
However below doesnt seems to be working.
when LB_FAILED {
if{[active_members [LB::server]]<1}
HTTP::redirect "http://[HTTP::host]/error/404.html"} - JRahm
Admin
[LB::server] returns a list. You most likely want [LB::server pool].
HTH...Jason - Shivesh_Rege
Nimbostratus
Hi Jason,
[LB::server pool] doesnt seems to be working. - Colin_Walker_12Historic F5 AccountWhen you say it's not working, do you mean it's returning nothing, or that it's not returning what you want?
Colin - Shivesh_Rege
Nimbostratus
Hi Colin ,
Its not working is it not redirectig
http://[HTTP::host]/error/404.html location .If I do an http watch (Its giving Internet_connection_problem) .
Thanks
Shivesh - Colin_Walker_12Historic F5 AccountTry getting rid of the redirect and just re-writing the URI instead.
HTTP::uri /error/404.html
It's late in the session to be issuing a redirect to the client. They're likely expecting a server response at this point.
Colin - Shivesh_Rege
Nimbostratus
Hi Friends,
I tried all possible switches.It doesnt seems to be working .Kindly help me here if I am missing anything.Observation when disabled the nodes in pool still redirection was happening.However as I had got down possibly I am missing some small thing in here.
when LB_FAILED {
if{[active_members [LB::server pool ]] < 1 }
HTTP::redirect "http://www.google.com"}
when HTTP_REQUEST {
if {([HTTP::path] ends_with "/doc")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/minisite")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/fslink")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/ms")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/link")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/null-request")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/exttracking.dyn")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {([HTTP::path] ends_with "/ms_1020109.html")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {[string tolower [HTTP::host]] equals ("www.abcd.com") and ([HTTP::uri] equals "/")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {[string tolower [HTTP::host]] equals ("www1.abcd.com") and ([HTTP::uri] equals "/")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/nmhomepage.jsp"}
elseif {[string tolower [HTTP::host]] equals ("www.joinabcd.com") and ([HTTP::uri] equals "/")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/join.jsp"}
elseif {[string tolower [HTTP::host]] equals ("www1.joinabcd.com") and ([HTTP::uri] equals "/")} {
HTTP::redirect "http://[HTTP::host]/ecom/pages/nm/join.jsp"}} - L4L7_53191
Nimbostratus
You wouldn't have a fallback host configured on this virtual server's HTTP profile, would you? If so, that could be complicating matters.
-Matt - Shivesh_Rege
Nimbostratus
Hi Matt,
Nope I dont have a fallback host configured on Http profile.
Thanks & Regards,
Shivesh
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
