A permanent redirect tells the search engine that it has been moved from old URL to new URL. If your old page is indexed to search engine and you want to tell to search engine to point to new URL. Webmaster always prefer to redirect to domain.com to www.domain.com for search engine to improve the rank of domain. Some users open non-www domain.com and some users open www.domain.com
Here’s an example
Add the following lines of code to your Global.asax file, replacing non-www domain.com with your site www.domain.com.
void Application_BeginRequest(object sender, EventArgs ex)
{
if (HttpContext.Current.Request.Url.ToString().Trim().ToLower().Contains("http://DOMAIN.COM"))
Response.RedirectPermanent("http://www.domain.com");
}
Download
Global.asax (1.15 kb)