Forum Discussion
nathe
Oct 21, 2011Cirrocumulus
Redirect Based on Content
Hello all. Hope you can help. Not new to f5 but new to writing my own iRules.
Scenario: I want to redirect a user to an error page if a certain line of text is returned in the html bod...
nathe
Oct 24, 2011Cirrocumulus
Thanks Nitass
This works:
when HTTP_REQUEST {
Don't allow data to be chunked
if { [HTTP::version] eq "1.1" } {
if { [HTTP::header is_keepalive] } {
HTTP::header replace "Connection" "Keep-Alive"
}
HTTP::version "1.0"
}
}
when HTTP_RESPONSE {
Get the content length so we can request the data to be
processed in the HTTP_RESPONSE_DATA event.
if { [HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] < 1048577 } {
set content_length [HTTP::header "Content-Length"]
} else {
set content_length 1048576
}
log local0.info "Content Length: $content_length"
if { $content_length > 0 } {
HTTP::collect $content_length
}
}
when HTTP_RESPONSE_DATA {
if { [HTTP::payload] contains "Microsoft OLE DB Provider for SQL Server error"}{
log local0. "found OLE DB Error in response"
HTTP::redirect http://www.domain.com/error.asp
}
HTTP::release
}
Your guidance has been much appreciated.
N
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