I have a app that is setup on IIS 6.0. We are having trouble with Search Engine optimization with the default.aspx page. For Example when I type www.xxxxxx.com/default.aspx it should redirect to www.xxxxxx.com.
Can anyone please help me with this problem?
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (HttpContext.Current.Request.RawUrl == "/default.aspx")
{
Response.StatusCode = 301;
Response.Status = "301 Moved Permanently";
Response.RedirectLocation = "/";
Response.End();
}
}
}
}
Set the default document in IIS under the Documents tab. Once in the Documents tab, check "Enable default content page" and set Default.aspx as the first item (or only) in the list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.