HTTPS redirects and IIS

Not quite SharePoint specific, but sometimes necessary is the ability to redirect a http connection (port 80) to a https connection (port 443) for an entire site. While there are several ways to do this, one way that works for both SharePoint and IIS 6.0 in general is the following (*Note this is for SharePoint):

  1. Create a new html file in your 12 hive (this way your virtual directory for IIS is already created by the SharePoint instance).
    • httpsredirect.htm
  2. Place your file in the 12 Hive (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\httpsredirect.htm)
  3. Enter the following in the html file created in step 1:
    <html>
    <head>
    <title>HTTPS Redirector</title>
    <SCRIPT type="text/javascript">
    <!--
    if (location.protocol != 'https:')
    {
    window.location = 'https://'+ location.host + location.pathname + location.search;
    }
    // -->
    </SCRIPT>
    </head>
    <body>
    </body>
    </html>
    
  4. Define your custom error page in IIS for 404.3 errors for each SharePoint site which you want to be SSL only.
    • Select the 404.3 error in the properties dialog for the website.
    • Browse to the custom file you created (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\httpsredirect.htm)
    • Make sure that you are leaving the type as “File”
  5. Browse your site as http and you will be redirected to the SSL site.
Bookmark and Share
Leave a comment

3 Comments.

  1. I think the easier way is to extend the 443 site and then for the new site do a redirect setting in IIS to redirect to your 443 site. it works fine for me ..so its a no code solution

  2. I find it to be mostly a “flavor” thing. The method detailed in this posting utilizes only 1 web application within IIS, while extending the web app leaves me with 2 web applications to manage (in IIS). Having 2 web applications associated with the same content (at least in SharePoint) comes with a bit of administrative overhead, especially if both web applications are essentially the same.

    To me, extending a web application truly becomes useful when you truly need different functionality out of multiple sites accessing the same content (i.e. 1 application is forms authenticated with SSL and the other is Kerberos authenticated).

  3. liquidpooled,

    yeah you r right ..though site works fine for me ..but site search failed to work as SharePoint crawling failing after this configuration…also I observed that the site response is also slow in this case..

    Not sure if my approach is right or wrong..

Leave a Reply


[ Ctrl + Enter ]

Performance Optimization WordPress Plugins by W3 EDGE