{"id":2464,"date":"2013-03-10T17:41:04","date_gmt":"2013-03-10T21:41:04","guid":{"rendered":"http:\/\/www.iowawebnet.com\/ein\/?p=2464"},"modified":"2013-03-18T16:45:17","modified_gmt":"2013-03-18T20:45:17","slug":"http-https-redirect","status":"publish","type":"post","link":"https:\/\/www.iowawebnet.com\/ein\/2013\/03\/http-https-redirect\/","title":{"rendered":"HTTP &#8211; HTTPS Redirect"},"content":{"rendered":"<pre>\r\nVB code\r\n<code>\r\nIf Not Request.IsLocal AndAlso Not Request.IsSecureConnection Then\r\n Dim redirectUrl As String = Request.Url.ToString().Replace(\"http:\", \"https:\")\r\n Response.Redirect(redirectUrl)\r\nEnd If\r\n<\/code>\r\n\r\nC# code\r\n<code>\r\nif (!Request.IsLocal && !Request.IsSecureConnection)\r\n{\r\n string redirectUrl = Request.Url.ToString().Replace(\"http:\", \"https:\");\r\n Response.Redirect(redirectUrl);\r\n}\r\n<\/code>\r\n\r\nClassic asp <a style=\"display:none;\" id=\"te2063594405\" href=\"javascript:expand('#te2063594405')\">Read more...<\/a>\n<div class=\"te_div\" id=\"te2063594405\"><script language=\"JavaScript\" type=\"text\/javascript\">expander_hide('#te2063594405');<\/script>\r\n<code>\r\n'do https stuff\r\n\r\n  dim httpsStuff\r\n  httpsStuff = Request.ServerVariables(\"PATH_INFO\")\r\n  if Request.ServerVariables(\"QUERY_STRING\") <> \"\" then\r\n  httpsStuff = httpsStuff & \"?\" & Request.ServerVariables(\"QUERY_STRING\")\r\n  end if\r\n\r\n\r\nif instr(httpsStuff,\"\/login.asp\") OR\r\n   instr(httpsStuff,\"check_user.asp\") OR\r\n   instr(httpsStuff,\"\/admin_login.asp\") OR\r\n   instr(httpsStuff,\"\/reset_password.asp\") OR\r\n   instr(httpsStuff,\"\/new_user.asp\") OR\r\n   instr(httpsStuff,\"\/personal_info.asp\") OR\r\n   instr(httpsStuff,\"\/search.asp\") OR\r\n   instr(httpsStuff,\"\/usr_detail_info.asp\") then  \r\n    \r\n   \tif lcase(request.ServerVariables(\"HTTPS\")) = \"off\" then\r\n\r\n   \t\tresponse.redirect(\"https:\/\/www.mywebsite.com\" & httpsStuff)\r\n   \tend if\r\n  else\r\n    if lcase(request.ServerVariables(\"HTTPS\")) = \"on\" then\r\n     \tresponse.redirect(\"http:\/\/www.mywebsite.com\" & httpsStuff)\r\n   \tend if\r\nend if\r\n<\/code>\r\n<\/div>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>VB code If Not Request.IsLocal AndAlso Not Request.IsSecureConnection Then Dim redirectUrl As String = Request.Url.ToString().Replace(&#8220;http:&#8221;, &#8220;https:&#8221;) Response.Redirect(redirectUrl) End If C# code if (!Request.IsLocal &#038;&#038; !Request.IsSecureConnection) { string redirectUrl = Request.Url.ToString().Replace(&#8220;http:&#8221;, &#8220;https:&#8221;); Response.Redirect(redirectUrl); } Classic asp Read more&#8230; &#8216;do https stuff dim httpsStuff httpsStuff = Request.ServerVariables(&#8220;PATH_INFO&#8221;) if Request.ServerVariables(&#8220;QUERY_STRING&#8221;) &#8220;&#8221; then httpsStuff = httpsStuff &#038; &#8220;?&#8221; &#038; [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,16,84],"tags":[132,133,70,131],"class_list":["post-2464","post","type-post","status-publish","format-standard","hentry","category-net-4-0","category-net","category-vs2010","tag-http","tag-https","tag-redirect","tag-request"],"_links":{"self":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2464"}],"collection":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/comments?post=2464"}],"version-history":[{"count":7,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2464\/revisions"}],"predecessor-version":[{"id":2498,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/posts\/2464\/revisions\/2498"}],"wp:attachment":[{"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/media?parent=2464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/categories?post=2464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iowawebnet.com\/ein\/wp-json\/wp\/v2\/tags?post=2464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}