ASP.NET MVC 3は、全局リダイレクトを実現する簡単な方法です。
538 ワード
MVC 3は以下のコードで全局リダイレクトを実現します。
protected void Application_BeginRequest(object sender, EventArgs e)
{
string strUrl = Request.Url.ToString().Trim().ToLower();
if (strUrl.Contains("http://jb51.net"))
{
Response.RedirectPermanent(strUrl.Replace("http://jb51.net", "//www.jb51.net"));
}
}
実現例:http://jb51.net/about リダイレクト/www.jb 51.net/about