SQL PHP HTML ASP JavaScript articles and free scripts to download
Articles

HTTP error code and Message

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.
<?Php
header("HTTP/1.1 301 Moved Permanently");
header ("Location: newpage.php");
exit; 
?>
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.

Be the first to post comment on this article :

Search Engine Optimization and google articles
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer