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:
- Open Computer Management to manage your IIS Website.
- Right click on your site and select Properties.
- Under the Folder tab select "A redirection to a URL".
- Type in the new domain information in the text box below.
- 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.
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
Or .NET 4.5
Response.RedirectPermanent(URLString)
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.