kmiles has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks. I need a way to redirect a browser if the link the user clicks is invalid/returns 404 error. I can't do it directly in perl prior to the user click because the perl server is outside of our LAN and the link will only work from inside the LAN. Javascript?

Replies are listed 'Best First'.
Re: Redirect if hyperlink fails
by jasonk (Parson) on Jan 17, 2008 at 01:13 UTC

    The only way to do this is for your application to load the url, determine if it is a 404 or not, and then give the appropriate URL to the browser. Once the browser clicks a link and leaves your site, you don't have any more control over it.


    We're not surrounded, we're in a target-rich environment!
Re: Redirect if hyperlink fails
by moritz (Cardinal) on Jan 17, 2008 at 07:59 UTC
    On the server on which the 404 occurs you can install a custom error handler script that does the redirect - if you have access to that server.