Forum Discussion
Dayton_Gray_103
Nimbostratus
May 16, 2008Send 404 and redirect?
I have this irule:
HTTP_RESPONSE {
if { [HTTP::status] == "404"} {
HTTP::redirect "http://www.mysite.com/error/nopagehere.html"
}
}
Is there anyway to send a 404 status code to the browser and redirect to this page? The reason I need this is so that my nopagehere.html link doesn't get listed on search engines as a valid page HTTP::redirect is just issuing a 302 redirect to this page.
Thanks in advance!
- I don't think so. A redirect is defined by a 301 or 302 HTTP response with the new address in the "Location" HTTP response header. The 404 HTTP response does not have redirection defined as part of the response.
- Dayton_Gray_103
Nimbostratus
Would I be able to exclude the search engine user-agents in this iRule? That would probably help the situation out. I know this can be done in an HTTP_REQUEST but not sure how it would behave in an HTTP_RESPONSE. - Colin_Walker_12Historic F5 AccountI'm not quite sure I follow what you're trying to do. I think what you're looking for is to inspect the user agent on the inbound request, then check that value on the response to help determine an action? If so this should be pretty straight-forward. The user-agent should be cached for the duration of the iRule's execution (the whole connection) or you could store it simply in a local variable like:
set agent [HTTP::header" User-Agent"]
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