Automatically Redirect HTTP requests to HTTPS – IIS 6
MWahl | January 15, 2011 | 5:26 pmOften times we want to require users to sign into a web using https, but what a pain to give out a new site address. One solution is to create a Custom 403.4 page that redirects http requests to https.
To pull this off we need to head to the web server, and open the IIS manager and Verify SSL is required for the selected site.
1) Open IIS Manager (Start Menu\Programs\Administrative Tools or %SystemRoot%\system32\inetsrv\iis.msc)
2) Expand the Computer Name
3) Expand Web Sites
4) Right click the web site we wish to modify
5) Select “Properties
6) Select the “Directory Security” tab
7) Select “Edit” in the Secure Communications section
8) Check off the “Require secure channel (SSL)” option. (This will only allow pages on this site to be viewed only with https.)
9) Press OK and close all Properties windows
Next we create a HttpRedirect.htm file in notpad or notpad++ and save it to the root of where your website coentent is stored such as C:\InetPub or another directory.
————copy below——————————–
<!– beginning of HttpRedirect.htm file –>
<script type="text/javascript">
function redirectToHttps()
{
var httpURL = window.location.hostname+window.location.pathname;
var httpsURL = "https://" + httpURL ;
window.location = httpsURL ;
}
redirectToHttps();
</script>
<!– end of HttpRedirect.htm file –>
————copy above———————————-
Set the 403 error page to use this file instead of the regular error file
1. Head back to the IIS manager Expand Web Sites, Right click the web site you wish to modify, Select “Properties”
2. Select “Custom Errors” Tab, Select the “403;4″ error, Press the “Edit” button, Browse to and Select the HttpRedirect.htm file in directory you saved it in from the steps above, Press OK and close all Properties windows
That’s it! You are done!



lopsa




