我的要求是我们的SEO专家建议www.example.com/index.aspx
应加载为www.example.com for google index Canonical Issue
我尝试在global.asax中使用以下代码。 Index.aspx是站点的默认页面,因此抛出错误:“500 - 内部服务器错误。”
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"
}
}
答案 0 :(得分:0)
您可能希望用
包装它<script language="c#" runat="server">
</script>