Asp.net C# script for Permanent 301 Redirect 27 March 2009 Shawn-Hyde Code, Quick Tips (0) Here is the code, add this to your global.asax file: <script language="C#" runat="server"> // This code is provided free for all, enjoy! ©2008-2009 Shawn Hyde http://shawnhyde.com protected void Application_BeginRequest(Object sender, EventArgs e) { if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://olddomain.tld")) { HttpContext.Current.Response.Status = "301 Moved Permanently"; HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://olddomain.tld","http://newdomain.tld")); } } </script>