Remove Duplicates Using .Net

Read my post about Google Hating duplicate content.

If you want to help remove it from an IIS .Net web site you’ll want to include this following code.  What this code does is forces all the URL’s to be lowercase.  If a request for one with uppercase comes in then it redirects to the one with lowercase.

IMPORTANT NOTE: This will change your URL parameters.  You shouldn’t use this if your parameters are case sensitive.

private void Redir301(string Url)
    Response.Status = “301 Moved Permanently”;
    Response.AddHeader(“Location”, Url);
protected void Page_Load(object sender, EventArgs e)
    if (Request.Url.ToString() != Request.Url.ToString().ToLower())

On Page load, this will check the URL to see if there is any uppercase characters.  If there is, it 301 redirects to lower case.  That’s the Redir301 method.

You want to use that redirect method and not “Response.Redirect(URL)”.  Why?  Response.Redirect is known as a 302 redirect.  302 is a “temporary” redirect while 301 is a permanent redirect.  Google is a less likely to differentiate the redirect if it is a 302.

They both have their place, but in this case you will want a 301 redirect.

Leave a Reply

Your email address will not be published. Required fields are marked *

− two = 7

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>