Forum Discussion
Response redirect ONLY if browser URI gives an 404 error
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.com/xyz". You ONLY want to redirect if
"http://xyz.com/xyz" returns a 404. What you do NOT want is if a image request "http://xyz.com/imagexyz" within the page
returns a 404 and the response event redirect the user.
1) request --> "http://xyz.com/xyz" // return 404
2) request --> "http://xyz.com/imagexyz" // return 404
3) response --> redirect to external URL
1) request --> "http://xyz.com/xyz" // return 200
2) request --> "http://xyz.com/imagexyz" // return 404
3) response --> NO redirect happens
Hopefully that made sense.
Thank you in advance.
Regards,
TRX
- hooleylistCirrostratusHi TRX,
- Hello Aaron,
I would ONLY redirect the user IF the URL in the browser returns a 404. All the referenced URLs within the page should NOT cause a redirect.
Is there a way to determine if the ONLY the browser URL returns a 404 or NOT?
Hope that made sense.
Regards,
TRX
- nitassEmployeei am confused. how can we differentiate 1 and 2?
- nitassEmployeethanks for explanation.
- Thanks for the clarifcation!
- ArieAltostratusTo clarify, I assume that you want the redirect only if the web server returns a 404? You mentioned the browser (client), but it sounds like you want to intercept 404s.
We had this requirement years ago. Digging up some old code, here's how I handled it:
when HTTP_RESPONSE {
if { ([HTTP::status] equals "404") } {HTTP::redirect ... - Posted By trx on 06/11/2011 12:50 AM
If 1 returns a 200, but 2 returns a 404, do NOT redirect anywhere.
Hi,
- Thinking about this, maybe an image is a bad example. What other types of request causes a browsers to redirect for if NOT images? Hi,
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