Forum Discussion
Apr 25, 2011
Response redirect ONLY if browser URI gives an 404 error
Hello All, How does one redirect to an external URL in the response ONLY if the URI in the browser returns a 404? ex) When you hit a page and the URL in the browser is "http://xyz.co...
nitass
Jun 11, 2011Employee
thanks for explanation.
as Aaron mentioned, browser won't redirect image. it just doesn't display the image.
If you send a 404 in response to an image, the browser should just not display the image. It shouldn't cause the page which referenced the object to be redirected.
[root@orchid:Active] config b virtual bar list
virtual bar {
snat automap
pool foo
destination 172.28.17.88:http
ip protocol tcp
rules myrule
profiles {
http {}
tcp {}
}
}
[root@orchid:Active] config b rule myrule list
rule myrule {
when HTTP_RESPONSE {
if {[HTTP::status] eq 404} {
HTTP::redirect "http://www.google.com"
}
}
}
there is dog.gif in index.html and i renamed it. when browsing the index.html, even browser got redirect but it just didn't display the image.
GET /dog.gif HTTP/1.1
Accept: */*
Referer: http://172.28.17.88/
Accept-Language: en-US
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; InfoPath.3; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Host: 172.28.17.88
Connection: Keep-Alive
Cache-Control: no-cache
HTTP/1.0 302 Found
Location: http://www.google.com
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
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