This is the code I use to redirect from www. to non www. version of my site
void Application_BeginRequest(object sender, EventArgs e)
{
string authority = Request.Url.Authority;
if (authority.StartsWith("www."))
{
authority = authority.Remove(0, 4);
string newUrl = "http://" + authority + Request.Url.PathAndQuery;
Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", newUrl);
Response.End();
}
}
this is the tool I used to validate if the code above work as expected:
While everything works as expected for almost all users, some of them has complained they can't access the site. I logged in to their computer using TeamViewer and indeed, there was a problem. When they try to acces the site, FF and IE gives an error: it looks like the site you wanted isn't there.
What should be the problem ?