Santry Technology Solutions, Content Management, DotNetNuke, SharePoint Consulting
Register | Login
Saturday, October 11, 2008

Sections
  
About Us
  
Partners
Downloads
  
 WWWCoder.com Resource Directory

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


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 7/31/2008 12:11:21 AM by Anonymous
Comments:
Left on 7/11/2008 1:22:21 AM by Anonymous
Comments:
www.freeacode.com

its more usefull for me.
No ratings available.
Left on 7/11/2008 1:21:42 AM by Anonymous
Comments: freeacode.com

good
  

 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