0

当我尝试从网址中删除 www 时:

www.jeans.com.vn

结果是:jeans.com.vn/default.aspx

我也不想要/defaul.aspx

我怎样才能删除它?

我的代码:

if (Request.Url.Host.StartsWith("www") && !Request.Url.IsLoopback)
{
    UriBuilder builder = new UriBuilder(Request.Url);
    builder.Host = Request.Url.Host.Replace("www.", "");
    Response.StatusCode = 301;
    Response.AddHeader("Location", builder.ToString());
    Response.End();
}

谢谢你的帮助!

4

1 回答 1

2

只需设置Path为空或“/”:

builder.Path = "/";
于 2013-02-05T03:07:04.923 回答