可以請你告訴我,如何使301永久重定向在asp.net?如何使301永久重定向在asp.net
我在Global.asax文件編寫的代碼,但我的Web客戶端說,這是行不通的,
我已經寫在Global.asax文件follwing代碼:
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().ToLower().Contains(
"http://lsatfreedom.com"))
{
HttpContext.Current.Response.Status =
"301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location",
Request.Url.ToString().ToLower().Replace(
"http://lsatfreedom.com",
"http://www.lsatfreedom.com"));
}
}
是它有用嗎? 請幫忙。
謝謝
如果你想整個網站重定向爲什麼不IIS重定向? – Shoban 2011-01-21 04:40:34
請告訴我如何檢查它是否工作? – tina 2011-01-21 04:51:41
如果是IIS7,請檢查以下鏈接:http://www.davelawlor.com/iis-7-setup-301-redirect – Shoban 2011-01-21 04:52:39