ASP.NET MVC3 实现全站重定向的简单方法
MVC3用以下代码实现全站重定向
protected void Application_BeginRequest(object sender, EventArgs e)
{
string strUrl = Request.Url.ToString().Trim().ToLower();
if (strUrl.Contains("http://phpstudy.net"))
{
Response.RedirectPermanent(strUrl.Replace("http://phpstudy.net", "http://www.phpstudy.net"));
}
}
实现如:http://phpstudy.net/about 重定向到 http://www.phpstudy.net/about
«
»