MVC3用以下代码实现全站重定向
复制代码 代码如下:
protected void Application_BeginRequest(object sender, EventArgs e)
{
string strUrl = Request.Url.ToString().Trim().ToLower();
if (strUrl.Contains("http://zyiz.net"))
{
Response.RedirectPermanent(strUrl.Replace("http://zyiz.net", "//www.zyiz.net"));
}
}
实现如:http://zyiz.net/about 重定向到 //www.zyiz.net/about