In our site we will we use http error codes to give appropriate error message and advise visitors to visit correct location by using various commands and codes. Here are some examples
301 Moved permanently
We have one old page and now we found that this is no longer required and visitor should go to another page. Just deleting the page or changing the navigation links pointing to the page is not enough. Other websites or search engines might kept links pointing to our page which is not in our control . To manage such situation we just keep the file with the following code inside it.
header("HTTP/1.1 301 Moved Permanently");
header ("Location: newpage.php");
The above code is written in PHP. The first line says about the error type and give the message saying the page is no longer exit. The second line will redirect the visitor auotmatically to a different page marked for this. If you don't want automatic redirection then you can show a message and ask the visitor to click a link to move away.
echo "This topic is moved or deleted, return to <a href=http://www.plus2net.com>Home page</a>";
The last line may not be required. Just a second line of protection if you have any code below it to.
404 Not found
The required page is not found in the server so the visitor can be redirected to a custom error page saying sorry or any other message. This can be achieved by using .htaccess file or your web host can give you this page from your control panel.