Memorise

IIS7 redirect HTTP to HTTPS

30% off your entire order at GoDaddy.com!

If you are looking to re-direct Outlook Web Access then follow this article

The method of setting up an IIS7 redirect HTTP to HTTPS is to Require SSL on the site or part of the site and set up a custom 403.4 error page. To do this, just following these steps:

  1. Install your SSL certificate in IIS 7 and bind it to your website
  2. In IIS, click on the site name, and go to the SSL Settings section
  3. Check Require SSL and Require 128-bit SSL and click Apply
  4. After doing this, users will normally receive error:
  5. Create a new text file and paste the following into it:

<html>
<head><title>Redirecting…</title></head>
<script language=”JavaScript”>
function redirectHttpToHttps()
{
var httpURL= window.location.hostname + window.location.pathname + window.location.search;
var httpsURL= “https://” + httpURL;
window.location = httpsURL;
}
redirectHttpToHttps();
</script>
<body>
</body>
</html>

6. Save the file as redirectToHttps.htm in your C:Inetpub directory

7. Back in IIS, click on the site name and double-click the Error Pages option

8. Click Add… and enter 403.4 as the Status code. Browse for the redirectToHttps.htm file you just created and click OK

9. Select the error code and press Edit Feature Settings…

10. Click the Custom error pages option and again browse for the redirectToHttps.htm file

11. Test the site by going to http://www.yoursite.com and making sure it redirects

A caveat of using a custom error page to do an IIS7 redirect from HTTP to HTTPS is that the web browser must have JavaScript enabled for the redirection to work.

If you get “Lock violation” error in IIS 7.5

All you need to do is to open file “%windir%System32inetsrvconfigapplicationHost.config” and remove ‘defaultPath’ from the following line:

<httpErrors lockAttributes=”allowAbsolutePathsWhenDelegated,defaultPath”>

Thanks to this Thread: http://forums.iis.net/t/1159721.aspx


Categorised as: Microsoft, Networking


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.