Forum Discussion
Juan_María_Rodr
Nimbostratus
Mar 02, 2006redirect and loop, please help
Hello.
Could anyone tell me why this iRule ends in a loop?
when HTTP_REQUEST {
if { [HTTP::host] equals "www.pepito.com"} {
HTTP::redirect "http://www.pepito.com/maintenance/index.html"
}
}
Thank you.
- JRahm
Admin
The redirect is using the same host that the if condition is looking for. Are you trying to match for an empty URI? If so, try something like this:when HTTP_REQUEST { if { ([ string length [HTTP::uri] ] <= 1) } { if { [HTTP::host] equals "www.pepito.com"} { HTTP::redirect "http://www.pepito.com/maintenance/index.html" } } }
- Juan_María_Rodr
Nimbostratus
Thank citizen, but I'd like that when I access to www.pepito.com, it is redirected to www.pepito.com/maintenance/index.html. I don`t know how to do that. For example, I tried these: - JRahm
Admin
My previous post should function the same as your 2 attempt. - The value of HTTP::uri will never by empty. It will at least always contain the beginning "/" character. So your conditions of the URI equalling "" will never pass.
when HTTP_REQUEST { if { ([string tolower [HTTP::host]] equals "www.pepito.com") and ([string tolower [HTTP::uri]] ne "/maintenance/index.html") } { HTTP::redirect "http://www.pepito.com/maintenance/index.html" } }
- Juan_María_Rodr
Nimbostratus
Thank you very much. It works. - JRahm
Admin
By including the brackets on the HTTP::uri, you are setting a variable name to the value of HTTP::uri. For example, if your URI is only "/", then the equivalent would be
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