Forum Discussion
redirect not working
I have below scenario works without redirect if statement . when i add the if statement for uri redirect getting a reset.
The reason your redirect to "/testpage" isn't working is because you aren't providing the full URL and you are using "starts_with" instead of "eq". When you use "starts_with" "/" you will receive a redirect for every single path that comes to the F5 causing a redirect loop, which is what you are probably experiencing. I have come up with the following rule that should work, assuming this is HTTP and not HTTPS, if it's HTTPS you just have to replace "http://" with "https://" and it will work appropriately.
when HTTP_REQUEST priority 500 { if { [active_members pool1] != 0 } { if { [HTTP::uri] == "/" } { HTTP::redirect "http://[HTTP::host]/testpage" } } else { if { ( ( [class match [IP::client_addr] eq "whitelist"] ) && ( [active_members pool2 ] > 0 ) ) } { pool pool2 } else { HTTP::respond 503 content [ifile get "applicationdown.html"] } } }
- sandikskNimbostratus
Thanks for your response , above logic works only when pool1 members are not equal to zero then simply it goes to uri redirect ,but when the else condition is met and traffic is going to pool2 , i even want the HTTP::redirect "https://[HTTP::host]/testpage". If I apply If for pool2 too its not working .Can you assist me.
If that's the case then your original iRule with the "==" correction on the URI match should work. I have also made some formatting changes as well so I would use the iRule in this comment.
when HTTP_REQUEST priority 500 { if { [HTTP::uri] == "/" } { HTTP::redirect "http://[HTTP::host]/testpage" } if { [active_members pool1] == 0 } { if { ( ( [class -- match [IP::client_addr] == "whitelist"] ) && ( [active_members pool2 ] > 0 ) ) } { pool pool2 } else { HTTP::respond 503 content [ifile get "applicationdown.html"] } } }
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