0
我的問題是這樣的,我的www網頁上有一個來自azure的錯誤404,但我只是輸入domainname.com,然後工作,因爲沒有問題301使用global.asax從domainname.com重定向域名www.domainname.com
我想它被稱爲:
domainname.com並同時以www.domainname.com去工作,而不是拿出404錯誤做。
我已經嘗試了她在Global.asax的
protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
string currentUrl = HttpContext.Current.Request.Path.ToLower();
if(currentUrl.StartsWith("http://mydomain"))
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", currentUrl.Replace("http://mydomain", "http://www.mydomain"));
Response.End();
}
}
注:MYDOMAIN必須站在.COM