简体   繁体   English

我可以从网址中删除“default.aspx”吗?

[英]Can i remove the “default.aspx” from the url?

When i try remove www from url: 当我尝试从网址中删除www时:

www.jeans.com.vn

the result is: jeans.com.vn/default.aspx . 结果是: jeans.com.vn/default.aspx

I don't want the /defaul.aspx too. 我也不想要/defaul.aspx

How can i remove it? 我怎么能删除它?

My code: 我的代码:

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();
}

Thanks for any help! 谢谢你的帮助!

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

builder.Path = "/";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM