When a page is removed from your website, your webserver will usually return a "404 Page Not Found" error (also known as just "404".) When a Search Engine spider encounters missing pages, of course the links will be removed from the indexes. At the very least, a redirect avoids the 404 by telling the spider that the content for the page can be found elsewhere. It also tells the search engine that the "old" URL should stop being checked (and indexed) in essence replaced with the "new" URL.
By the way, the 404 and 301 are the HTML header response codes that your webserver will respond with when it receives a request. As you might know, when a user enters a URL on their web browser and tries to visit your site, the web browser establishes a connection with your server and makes a "request" for web content. The server then sees if it understands the request, and if it does, returns the content along with a response code of 200 (the "all ok" response code.) However, if your server does not know about the request, it will instead respond with the 404 indicating that "no such page was found here".
I am discussing this because this presents an interesting restriction of the 301 redirect technique which is that these response codes are ONLY under your control while the page is being "prepared" on the server for delivery to a web browser. Because of this, it is NOT possible to change a page's header code unless you have access to the server-side code for the page. In other words, you are only able to use a 301 redirect if your server (or hosting company) has provided you with a technology like ASP, ASP.NET, JSP, PHP, PERL, etc. You cannot change a page's header via the HTML for the page!
With that restriction out of the way and assuming you do have access to the server-side code for your website, a 301 Redirect can be performed on a page-by-page basis. Simply edit the page you wish to redirect and add the code according to the list below! It is not necessary to have anything else on the page but the redirect code.
ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>
ASP .NET Redirect
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>
PHP Redirect
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
JSP (Java) Redirect
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>
0 comments
Post a Comment