Forum Discussion
Dayton_Gray_103
Nimbostratus
Dec 15, 2008404 question
I am trying to send a redirect to a 404 page but also return a 404 status code to the web browser. How is this accomplished? I have the following iRule, but it only returns a blank page:
when HTTP_REQUEST {
if { [HTTP::uri] contains "notfound.jsp" } {
event disable all
}
}
when HTTP_RESPONSE {
if { [HTTP::status] == "404" or [HTTP::status] == "500"}{
log local0. "A 404 was hit"
HTTP::respond 404 Location "http://www.validdomainhere.com/error/notfound.jsp"
}
}
I would rather not host the content on the BigIP, so I'm hoping to redirect to a valid page but keep the 404 error code.
Thanks!
- hoolio
Cirrostratus
If you send a 404, the client won't use the Location header for anything. If you want LTM to send a 404 with content, you'd have to send the content from the iRule. I suppose you could use HTTP::retry to do something fancy like get the response content from another host and send that back to the client, but it would probably add a significant amount of complexity to your configuration and latency to the response time.
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