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/mainten...
Mar 02, 2006
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.
Another option would be the following (if you want all requests to go the maintenance page).
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"
}
}
This will redirect all requests to the www.pepito.com domain to the maintenance page except for ones already going to the maintenance page (thus avoiding the infinite loop).
I threw in some "string tolowers" so that it would match mixed case requests as well.
Citizens example will redirect either "http://www.pepito.com" or "http://www.pepito.com/" while mine will redirect all requests. Pick your choice...
-Joe
}
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