Forum Discussion
James_Richter_1
Nimbostratus
Mar 12, 2013multiple redirect iRules on a VS
We have a single VS that normally uses a iRule that does a redirect for / to /irj/portal/ When there is maintenance on that system, we want to have a redirect to another web server active but curren...
Kevin_Stewart
Employee
Mar 12, 2013The problem is that you have multiple redirect invocations in the same HTTP request. When you compile the iRule the two HTTP_REQUEST events are mashed together, so you end up with something like this:
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::redirect "/irj/portal/"
HTTP::redirect "/maintenance site"
}
}
This is a bad thing. Here's a thought. Given the way that events are mashed together on compile, why not modify your iRules to look something like this:
Regular iRule:
when HTTP_REQUEST {
if { [info exists MAINTMODE] and $MAINTMODE eq "on" } {
HTTP::respond 302 Location "maintenance site"
} elseif { [HTTP::uri] equals "/" } {
HTTP::respond 302 Location "/irj/portal/"
}
}
Maintenance mode iRule:
when HTTP_REQUEST priority 10 {
set MAINTMODE "on"
}
This way, the MAINTMODE variable only exists in the request when you add the maintenance mode iRule, and the higher priority ensures that it's available before the condition is checked.
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