By default, SharePoint takes you to its own 404 NOT FOUND page if you enter an Url which does not exist in the site.
It is very easy to customize this behaviour and let SharePoint redirect 404 errors to the page you want to.
The important file that manages this 404 redirection is –
This HTML file controls the redirection
So, to create your own custom 404 redirection, all you need to do is:
1) Make a copy of sps404.html, for example – mysite404.html – and place it in the same folder 12TEMPLATELAYOUTS1033
2) Modify the STSNavigate with your page Url:
Remember that as long as the Url is valid, your redirection will work
3) You have to now set the mysite404.html as your 404 redirection page for your web application.
You can do this via the SharePoint object model. Instead of writing a console app to do this, it is always better to deploy the 404 redirection using a feature which would set the 404 redirection.
Note: The FileNotFound is set to NULL by default
Note: You can *only* set a 404 redirection per web application
Deploy the feature, activate it and your custom 404 redirection is ready to go!