Thursday, October 6, 2011
Sometimes we forgot to see the basic need of SEO and find canonical URL issue of our sites when search engine fetch our site same page in both upper and lowercase URLs result. Let’s take my site example to resolve this issue. I have built my site named www.dotnetplace.com in ASP.NET 4.O and is running under IIS6 & IIS7.
In this article, I will make obvious how to handle canonical URL issue in asp.net page. Upper case letter in the URL will not negative effect in your page rank in the search engines. But, duplicate content displaying in the Search engine with same URL have cap and no caps. For example, Google search http://www.dotnetplace.com/default.aspx and http://www.dotnetplace.com/Default.aspx pages. Now, Google will be considered that these are two pages. Google will not ignore upper case and lower case letter in the domain. When I was working, I have found in my search that URL’s are not case sensitive. You can load same pages name with upper case and lower case letter in URL, it will display you same content as shown below.
Above links with uppercase and lowercase URLs return same page with same content and information. But search engine considers that these are two different pages and search rank has been evaporating rapidly.
To resolve this problem, I have implemented 301 redirects, which automatically converts URL into lower case to fix the search engine ranking.
Add following code into your Global.asax file.
protected void Application_BeginRequest(object sender, EventArgs e)
if (Regex.IsMatch(HttpContext.Current.Request.RawUrl.ToString(), @"[A-Z]"))
string LowercaseURL = HttpContext.Current.Request.RawUrl.ToString().ToLower();
Response.Status = "301 Moved Permanently";
Note: If someone writes, upper case in URL then it will be converted into lower case.