So there has been a whole lot of focus lately on SEO related optimization. SEO schizophrenia comes when your losing ranking due to a subdomain or domain is added to the address bar incorrectly and the domain has to be redirected via DNS.
For example:
mikedopp.com is a domain my company uses internally. So there is no site on the Internet. So the DNS server or register service has the the URL redirected. Causing a hit for mikedopp.com which once again does not have content so having a ranking on non content not very seo good.
www.mikedopp.com is the domain that hosts all the fun content. That I want SEO optimized and all the bots to see and love.
So being a web developer using asp.net2.0 C# and all the fun and love that goes with it.
I looked long and hard for a solution. Never the less I am fortunate enough to work with talented developer and he figured out a better way. That is was how this code came about. Thanks Joe Levi.
I would recommend as would Joe to put this into a usercontrol page load that loads with every stinking page. That way to assure coverage.
1: protected void Page_Load(object sender, EventArgs e)
2: { 3: string strServerName = Request.ServerVariables["SERVER_NAME"].ToLower();
4: if ((Request != null) &&
5: (strServerName.IndexOf("www") == -1) && 6: (strServerName.IndexOf("prototype") == -1) && 7: (strServerName.IndexOf("admin") == -1) && 8: (strServerName.IndexOf("localhost") == -1)) 9: { 10: Response.Status = "301 Moved Permanently";
11: Response.AddHeader("Location", "http://www." + Request.ServerVariables["HTTP_HOST"] + Request.ServerVariables["URL"]); 12: Response.End();
13: }
14:
15: }