Register | Login
Friday, August 08, 2008

Sections
  
About Us
  
Hosting Provided by Server Intellect
Partners
Downloads
  
 WWWCoder.com Resource Directory

Don't Damage Your Site's Ranking
3/26/2004 4:19:53 PM

Here's some quick tips on implementing a 301 redirect for your site or pages. Make sure when you modify your site's structure that you account for search engine issues. We provide some code snippets here for you to implement in order to maintain your site's ranking.

Making sure your site comes at the top of listings of search engines are probably one of the main issues many Webmasters concern themselves with. One thing that can impact search engine rankings and listings is changing a site's structure. This could be changing file names, like what commonly happens when moving a site from a static HTML site to one that is driven dynamically. Another issue could come from domain name consolidation where you have several domains names and wish to consolidate them into one domain. This is common when a company decides to change marketing strategy or comes through consolidation.

In this article we'll focus on some issues of consolidating domains into one domain, or even changing page references and dealing with search engines.

301 Redirects

Whenever you want to move or change your domain to something else you should always use a 301 Redirect. 301 Redirects are included as part of the HTTP header information sent to the browser or requesting client. The 301 informs the requesting client that the site or resource being requested has been permanently moved. It is best to include this information for search engines in order to prevent a negative impact on your search engine ranking. For example, say I have two domains, somedomain.com and someotherdomain.com, and both these domains point to the same content. Some engines consider multiple domains pointing to the same spamming their engine and this could adversely affect your ranking on that engine. Another issue is if you want to do a branding change and as part of the new brand change the domain name. It is not simply a manner of submitting the new domain to the search engines and expecting your new domain to be indexed in the search results. If your old domain exists in their index with identical content, then most likely the search engines will ignore your submission. In addition, many of the major search engines consider posting multiple domains with the same content "spamming", and it could negatively affect your site's ranking.

Bring 301 redirects to the rescue. As mentioned the 301 code sent in the header information informs the search engine that you no longer want the requested domain to be the focus, it tells them that you moved your site to a new domain. It's kind of like filling out a change of address form at the post office where yes, you'll still get mail to the old address, but the post office knows to forward it on to your new address. Eventually all mail will go to the new address and the old address is no longer associated with your mail. This is what we want to do with our old domains, let them know we moved. By doing this you can avoid confusion with search results, and limit the adverse affects on your site's ranking with the new domain name.

301 Redirects via IIS

One way of accomplishing this is to use IIS and letting it know that the domain has moved. Simply go to the old site and instead of pointing to a folder location for your site, change it to do a permanent redirect for the resource. You can use the following directions to accomplish this in IIS:

  1. Open Computer Management to manage your IIS Website.
  2. Right click on your site and select Properties.
  3. Under the Folder tab select "A redirection to a URL".
  4. Type in the new domain information in the text box below.
  5. Select "The exact URL entered above" and "A permanent redirection for this resource" in order to ensure that the 301 header will be sent to the client.

301 Redirects via Code

Many people use an ISP to host their sites and may not have access to the Web server settings. The following code will provide you with how to redirect using server-side code via ASP.Net.

There are many ways you can accomplish this, you could intercept the request via a HTTP handler, but in this example we'll simply provide a method at a file level in the Page_Load event.

C#

<script runat="server"> 
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.someotherdomain.com/page.aspx");
}
</script>

In VB.Net

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
  Response.Status = "301 Moved Permanently"; 

Response.AddHeader("Location","http://www.someotherdomain.com/page.aspx")
End Sub

You can also perform a redirect for your entire domain via code, by first checking the domain of the request, if the domain does not match the domain that you want to be the primary, then send a 301 redirect and redirect them to the appropriate file and domain. This could be done either in the global.asax or via a HTTP handler. Remember, in order to perform a redirect, the requested file will need to be processed by the ASPNet_ISAPI.dll, this means by default they're either aspx files. You can change this setting via IIS if you need to, but if you have that ability then you can change the 301 error at a server level.

Redirect Your Legacy ASP Files

Now to complete this article, many of you may be porting ASP files over to ASP.Net. Let's provide some code to let the search engines know that your site should be redirect

<%@ Language=VBScript %> 
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.someotherdomain.com/page.aspx"
%>

So you may be asking yourself, "That seems like a lot of effort, can't I just use response.redirect("http://www.somedmoain.com") and redirect the client that way?"

Response.redirect is great for moving to another page within your application, but they do not send the 301 header which informs a client that this is a permanent change for the requested resource.

Hopefully this article provides you with some tips when dealing with search engines. Remember search engines constantly change their algorithms, it's up to you to try and figure out how make sure your site will be able to deal with them.

By: Patrick Santry, Microsoft MVP (ASP/ASP.NET), developer of this site, author of books on Web technologies, and member of the DotNetNuke core development team. If you're interested in the services provided by Patrick, visit his company Website at Santry.com.


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
Left on 11/11/2007 7:52:49 PM by Anonymous
Comments: Hello! Good Site! Thanks you! sxeyrzudmlgcgu
Left on 7/13/2007 2:47:38 AM by Anonymous
Comments:
No ratings available.
Left on 5/19/2007 6:42:10 AM by Anonymous
Comments: http://donneciucciacazzi.scommesse.yi.org donne ciuccia cazzi
http://videomxxp.blominfo.com.pl video gratis fighe pelosissime
http://risolutosposa.bogatek.pl risoluto sposa
http://caffetteriafranchising.bogatek.pl caffetteria franchising
http://caneuina.blominfo.com.pl cane
http://spiandoilsexdelmattinoiv.bogatek.pl spiando il sex del mattino iv
http://professoressafiga.scommesse.yi.org professoressa figa
http://fichegtwx.blominfo.com.pl fiche bollenti
http://aquarjfs.blominfo.com.pl aqua
http://donneinlingerie.scommesse.yi.org donnein lingerie
http://caninxxe.blominfo.com.pl cani che scopano fighe giovani com
http://heyhqgm.blominfo.com.pl hey
No ratings available.
Left on 10/10/2006 11:43:54 AM by Anonymous
Comments: This put my site in supplemental listings on google, as google has bug.
Left on 9/24/2006 10:35:37 AM by Anonymous
Comments: thanks.  helped me a lot.
Left on 7/31/2006 2:01:10 AM by Anonymous
Comments: Comments from the following blog: Chris Hammond, located at: http://chrishammond.com/blogs/archive/2006/07/31/Asp_net_301_redirects.aspx
No ratings available.
Left on 2/24/2005 9:07:40 AM by Anonymous
Comments: Very helpful information. I think there is an error in last example with VBScript. Response.AddHeader should be with parenthesis
Left on 1/19/2005 11:54:43 PM by Anonymous
Comments: Very nice!  Should the AddHeader be an AppendHeader?
Left on 11/1/2004 6:41:26 AM by Anonymous
Comments: What about passing the variables in the URL?  For exxample sending file1.aspx?id=100 to file2.aspx?id=100 with 301 Moved Permanently?
No ratings available.
Left on 8/11/2004 9:58:15 AM by Anonymous
Comments: Pretty good Info but which site gets the clicks registered from google!
Left on 5/21/2004 9:24:48 PM by Anonymous
Comments: Thank you. Does anyone know that how can i do this redirection on .htm pages.
http://www.cibilliyet.com
Left on 5/1/2004 11:08:34 AM by Anonymous
Comments: Just what I needed at a time I needed it, and with legacy code too!

Chris Lang
http://www.keywebdata.com
Left on 4/30/2004 6:01:21 PM by Anonymous
Comments: FYI Dear Reader: If you look at this site's sub title "The .Net Portal Developer's Resource Site", I think you would then understand why the article only covers IIS.
No ratings available.
Left on 4/30/2004 5:09:42 PM by Anonymous
Comments: FYI, dear Author:
a) some people use Apache, PHP, Perl
b) Code 302 Moved is also recognized by Google...
Left on 4/29/2004 4:17:36 AM by Anonymous
Comments: A must bookmark. Will definately be helpful sometime or the other.
Left on 4/27/2004 5:34:03 PM by Anonymous
Comments: Whoops! Wish i would have known this a month ago.
Left on 4/27/2004 12:54:06 PM by Anonymous
Comments: Thank You! Very Helpful
No ratings available.
Left on 4/26/2004 1:03:59 PM by Anonymous
Comments: i appreciate becoz this article provides the information that is not easy to find
Left on 4/26/2004 11:54:23 AM by Anonymous
Comments: One way to deal with the html to aspx is to modify IIS so it will process html files via ASP.NET. The write an httphandler to intercept ay requests for the old html file. You could create a lookup table to relate the old file with the new one, or handle the html file directly. This article will show you how to create the lookup script: http://www.wwwcoder.com/main/parentid/434/site/2295/68/default.aspx
  - P. Santry
No ratings available.
Left on 4/26/2004 11:03:17 AM by Anonymous
Comments: Needs to cover one other situation -- converting static .htm or .html  files to aspx
Left on 4/25/2004 6:28:24 PM by Anonymous
Comments: Thanks
Left on 4/25/2004 4:14:18 AM by Anonymous
Comments: Good stuff
Left on 4/14/2004 10:19:03 AM by Anonymous
Comments: Just check out the referrer logs, Scott Watermasysk posted a blog item on 301 redirects and how it affects weblogs: http://scottwater.com/blog/archive/2004/04/14/PermanentRedirects.aspx

P.Santry
No ratings available.
Left on 4/2/2004 3:17:44 PM by Chris Hammond
Comments: Great article! Wish I had known this about 3 weeks ago, but it will still help me out! -christoc
Left on 3/30/2004 2:30:25 AM by Anonymous
Comments: Helpfull informations :)
  

 Latest Articles
  

 Latest News
  

 

Spotlight
Syndication

 


 


Digg This
 


DotNetNuke Platinum Benefactor

  
 

 Terms Of Use | Privacy Statement
 Copyright 2008 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970