/// <summary> /// 페이지 요청시 호출되는 이벤트 /// luckshim /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void Application_BeginRequest(Object sender, EventArgs e) { #region https 및 www 관련 컨트롤 //실서버에서만 작동한다.(개발엔 강요하지 말자.^^) if (Request.IsLocal == false) { //https 사용여부 var useHttps = ConfigurationManager.AppSettings["UseHttps"].ToString(); //www 사용여부 var useWWW = ConfigurationManager.AppSettings["UseWWW"].ToString(); var redirectUrl = Request.Url.ToString(); var host = Request.Url.Authority.ToLower(); //포트까지 제공함. if (!Request.IsSecureConnection && useHttps == "true") { redirectUrl = redirectUrl.Replace("http:", "https:"); } if (useWWW == "true" && host.IndexOf("www.") == -1) { redirectUrl = redirectUrl.Replace(host, "www." + host); } Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", redirectUrl); Response.End(); } #endregion https 및 www 관련 컨트롤 }
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.