0

My requirement is as our SEO professional suggests www.example.com/index.aspx
should be loaded as www.example.com for google index Canonical Issue

I also like to mention because of shared server we can’t access IIS server, and support people are not much cooperative.

I tried following code in global.asax. Index.aspx is a default page for the site so it is throwing error: "500 - Internal Server Error."

void Application_BeginRequest(object sender, EventArgs e)
{

    HttpContext incoming = HttpContext.Current;

    string oldpath = incoming.Request.Url.AbsoluteUri.ToLower();
    if (oldpath.Contains("index.aspx") == true)
    {
    HttpContext.Current.RewritePath("http://www.example.com", false);
    }
}

//Also tried following 
void Application_BeginRequest(object sender, EventArgs e)
{

    HttpContext incoming = HttpContext.Current;

    string oldpath = incoming.Request.Url.AbsoluteUri.ToLower();
    if (oldpath.Contains("index.aspx") == true)
    {
        Response.Redirect"http://www.example.com"
    }
}
Chris Morgan
  • 86,207
  • 24
  • 208
  • 215
Alvin
  • 11
  • 4

1 Answers1

0

You may want to wrap this with

<script language="c#" runat="server">
</script>
Xedecimal
  • 3,153
  • 1
  • 19
  • 22