Forum Discussion
redirect loop
Hi All.
Request help to resolve redirect loop.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains "abc.com"} { if { not ([HTTP::uri] contains "/abc/en") or not ([HTTP::uri] equals "/") } then { HTTP::redirect "http://[HTTP::host]" } } }
When the above irule is activated, abc.com/abc/en/* works fine, but when the http_host does not have any uri the irule is going into redirect loop.
abc.com -> abc.com -> abc.com -> .....
how can we resolve the redirect loop when uri is empty.
2 Replies
- Andy_Cohen_4986
Nimbostratus
Your problem is the HTTP::redirect "http://[HTTP::host]" statement. If you don't match the terms stated (contains /abc/en or equals / ) then you are telling the iRule to redirect to http://abc.com The redirected request hits the iRule, and then hits the redirect statement again. Why have you got the redirect in there? What are you trying to achieve? Hi Winnajeem,
the problem with your iRule is that "(not /) or not (/abc/en)" is alway true and therefor hits the redirect everytime.
To fix the redirect loop, you may try the iRule below...
when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains "abc.com"} then { if { ([string tolower [HTTP::uri]] starts_with "/abc/en") or ([HTTP::uri] equals "/") } then { Do nothing } else { HTTP::redirect "http://[HTTP::host]" } } }Cheers, 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