(814)806-1269  |   REQUEST A QUOTE     Register   Login   
Tuesday, September 07, 2010  
..:: Blog ::..
Request A Quote


  
Popular Entries
  
Categories
  
Santry Enterprises Weblog
27
HTML clipboard

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. 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.

Posted in: Development

Post Rating

Comments

There are currently no comments, be the first to post one.

Post Comment

Name (required)

Email (required)

Website

  
  Privacy Statement | Terms Of Use
Copyright 2010 by Santry Enterprises
Home  |  About  |  Portfolio  |  Blog  |  Contact