Ah, yeah your right not sure why I used on load event...
Any ideas on how to make it so it doesn't forward to the domain/default.aspx, I'm trying to keep the SEO on the main domain/
This works:
<script language="C#" runat="server">
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://olddomain"))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://olddomain","http://newdomain"));
}
}
</script>
However is forwards all to newdomain/default.aspx and then google index's the domain/default.aspx page instead of the domain itself.