Forum Discussion
404 status issue
I'm curious as this is weird behavior I've encountered with this set of code:
when HTTP_RESPONSE {
if { ([HTTP::status] equals "404") } {
if a 404 is return, then do a 301 redirect to our custom 404 page
HTTP::respond 301 Location "http:[HTTP::host]/portal/site/erp/404/"
return
}
}
Problem: If the page returns a 200 but there is a missing image, the redirect will take place. I was under the impression that the whole page has to returned 404 before to set the "HTTP::status" to true. Is that correct or am I missing something?
Any clarification is fully appreciated.
Thanks.
Regards,
TX
- Chris_MillerAltostratusA page is merely a collection of objects for which HTTP GET requests must be made. If for instance a page had 12 images, a 404 for any of them could trigger the rule. Also, HTTP::host shouldn't be used in HTTP_RESPONSE since there's no host header. You'll want to set a variable from HTTP_REQUEST and check the variable from HTTP_RESPONSE.
when HTTP_REQUEST { set hostvar [HTTP::host] } } when HTTP_RESPONSE { if { [HTTP::status] eq "404" } { if a 404 is returned, send a 301 redirect for our custom 404 page HTTP::respond 301 Location "http://$hostvar/portal/site/erp/404/" } }
- Hello ,
- hooleylistCirrostratusTX,
Recent Discussions
Related Content
* 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