html - Switch to SSL using a relative URL -


I would like to create a relative link that allows the existing protocol http to https . I worked at the last place, something was installed on the server so that you can do it, but I do not remember much about it and I did not know how it works.

The argument for this is that I do not require hardcod server names in files, which need to be moved between production and development environments.

Is there any way to work in IIS 6.0?


Edit:

I am using .NET, but the "link" I am creating will not be dynamically generated . If you really want knightly gritty details, then I am using a redirect macro in Umbraco for which the url has to be passed.

Here is a simple solution in VB.NET:

  import System Web. HTTTX public side subset SSSSSL (Boolean = Optional alternate biowal enabled) Request.IsSecureConnection then retard strHTTPS as string = "https://www.mysite.com" current. response. Clear (current) response. Status = "301 permanently gone" current. Response.Addheader ("Location", str HTPS & Current.Request.RawUrl) Current Response End () end if else if present. request. Present as the ISCQ Acquisition again dim strHTTP string = "http://www.mysite.com". response. Clear (current) Response .tats = "301 Permanently" turned on Present. Response.Addressor ("Location", St HTTP and Current Request.Row URL) Current. Enable Response.and () End and End SSL SSL (True) Disable SSL SSSSL (wrong)  

Usage:

It can add page_load of each page to your page or you can do something like I did and make a list of folders or pages that you want to secure in your Global.assx and set SSL according to the application_BeginRequest method accordingly. . And it will work with relative links and the HTTP or HTTPS status of a page will always be what you call it in code.

I have this website on many websites. But as an example, if you go, you will notice that it will automatically redirect to http because the home page does not need to be protected. And if you try to hit a page that requires security like

you can see that I am using 301 (permanent) redirects. The advantage here is that search engines will update their index based on the 301 redirect code.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -