Removing the "www" From the URL
6/28/2008 1:07:22 PM
For SEO purposes you don't want to have two separate pages having the same content. This could very well mean if you have "www." in your url, and without the "www." pointing to the same content, you may run into some issues. There are other reasons too. Read the article for more.
HTML clipboardFor SEO purposes you don't want to have two separate pages having the same
content. This could very well mean if you have "www." in your url, and without
the "www." pointing to the same content, you may run into some issues. There are
other reasons too. For example some sites recognize sites that send referrals to
them, like YouTube, if I embed a video in my site it will show the sites linking
to the video. The problem with YouTube it shows my "www." and without the "www."
as two separate sites even though their the same page. How do you make sure
everyone is using the domain without the "www."? Here's a little snippet of code
I use in some of my sites where I don't want to use the "www." prefix:
<script runat="server">
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Init
'check to see if they are hitting the
site using the "www" prefix.
If Request.Url.Host.ToLower().StartsWith("www") Then
'set the header
so it sees this as a permanent move.
Response.Status = "301 Moved Permanently"
'now redirect with the removed "www" from the URL.
Response.AddHeader("Location", Request.Url.Scheme & "://" & _
Replace(Request.Url.Host.ToLower,
"www.", "") & _
Request.Url.PathAndQuery)
Response.End
End If
End Sub
</script>
That will accomplish removing the undesired part of the URL without impacting
the page where your users want to go.
|