Tech Tips, News and Tribal Knowledge

All the news that fits!

Capture and Redirect HTTP to HTTPS with SharePoint 2007

SharePoint administrators are often asked to securely publish their sites either to the Internet, internally, or both. This is a fairly straightforward process of configuring your MOSS installation for SSL and publishing your site using any one of the numerous firewalls or proxy servers available on the market. But what happens if your users forget the site is SSL secured and enter http://your.moss.site instead of https://your.moss.site? Well, if you’ve properly secured your site and blocked HTTP traffic from the Internet, they receive the all too familiar 404 page not found error and you get a call asking why the site is down. If they are internal users and enter http://your.moss.site, they receive a 403.4 Forbidden: SSL is required… error.

What you want to do is intercept all HTTP calls to the site and redirect them to HTTPS while still allowing all direct HTTPS calls to process normally. This is pretty easy to do with a standard web site, but MOSS will behave differently because the full URL as well as the data is stored in the SQL database. Fortunately this problem is easy to overcome, but the solution is not immediately apparent.

The way to do this in SharePoint is to create an alternate access mapping combined with some clever port redirection as follows.

First, access your “Central Administration” site and navigate to the alternate access mappings configuration page. The AAM page is found at: “Central Administration > Operations > Alternate Access Mappings.” Change the view to your.moss.site’s “Alternate Access Mapping Collection” then select “Edit public URLs” and change the default URL from http://your.moss.site to https://your.moss.site and save.

Then, open the IIS management console and right click on your.moss.site , select “Properties” and change the TCP port to something random like, 8001.  Next, click the “Directory Security” tab and in “Secure Communications,” click “Edit” then check “Require secure channel,” click “OK.”

Now create a new site named “your.moss.site redirector” with a host header that matches the original site name.  This works because the IIS ports are different.  Click Next, Browse and create a new folder, name it “redirect”, or something similar. This folder will not contain any data. It exists only as an IIS requirement when creating a new site.

Finally, open the properties on your “your.moss.site redirector” site and click the “Home Directory” tab then select a “Permanent redirection for this resource.”  Redirect the site to https://your.moss.site and save. This completes the configuration process.

Now all requests for http://your.moss.site are automatically redirected to https://your.moss.site and direct requests for https://your.moss.site will work as expected.

This is how you do it with SharePoint 2007.  If you are using WSS, the procedure is essentially the same. Also, if publishing your site to the Internet, don’t forget to allow HTTP as well as HTTPS through the firewall so the redirector will be triggered.

17 comments

1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 4.00 out of 5)
Loading ... Loading ...

17 Comments so far

  1. Mark Arnold August 11th, 2008 12:20 pm

    Simple and effective. Why didn’t I think of that?

    Thanks!

  2. Vinod August 11th, 2008 9:12 pm

    i have multiple portals.right now i have 10 portals and it might increase rapidly…(http://*.vin.com) do we need to create a duplicate website for each portal we have… Is there a way to create one single website and use that for all diff portals…something like a wildcard.

  3. Craig Shrimpton August 12th, 2008 8:00 am

    Using a DNS trick, you can do wildcard redirection of sites with host headers. I’d need to do some testing to see if that’s possible with MOSS. In the meantime, do a search on “iis wildcard host headers” and take a look at this site: http://msmvps.com/blogs/bernard/archive/2005/03/22/39218.aspx

  4. [...] Here’s a good description of the problem and fix [...]

  5. Ringo October 15th, 2008 6:33 am

    We’re using the 403.4 error page to redirect, but we haven’t worked all the bugs out yet. (Think there’s something wrong with the cert.)

    ————

    function doLoad()
    {
    setTimeout( “rewriteURL()”, 0000 );
    document.getElementById(‘redirect’).innerHTML = window.location.href.replace(“http”,”https”);
    }

    function rewriteURL()
    {
    window.location.href = window.location.href.replace(“http”,”https”);
    }

  6. Riju January 5th, 2009 12:27 am

    I have mutiple sites in my single Sharepoint installation. When users try to hit the sites directly, how will they get redirected?
    For eg, if they hit sharepoint.com\site1 and sharepoint.com\site2, with your solution, they will be redirected to sharepoint.com homepage

    thanks much!

  7. Tracy February 18th, 2009 11:50 am

    Side note, if you are using IIS 7, follow the directions up to the paragraph about Permanent Redirection. Instead, open the Error Pages icon for the redirector site, and edit the 401 error. Check the radio button for “Respond with a 302 redirect” and enter your SSL site in the Absolute URL box.

  8. sanjay March 28th, 2009 12:03 pm

    Hi,

    The line here says
    select “Edit public URLs” and change the default URL from http://your.moss.site to https://your.moss.site and save.

    But u have mentioned that the site is already in https, ..then the default URL will be https://your.moss.site in AAM..

  9. sanjay March 30th, 2009 3:36 am

    Hi,

    can you please explain this line “select “Edit public URLs” and change the default URL from http://your.moss.site to https://your.moss.site and save.”

    As the site is already in “https” the default URL will already be pointing to https://your.moss.site..then what changes r u doing here?

  10. Craig Shrimpton April 3rd, 2009 11:57 am

    Sanjay,

    The web application was created as an http (non SSL) site so you need to change the AAM from http to https for the public URL. Are you thinking of the AAM pages, or the IIS site? I was referring to the AAMs in the post.

  11. links for 2009-04-21 @ Gene & Tesha April 21st, 2009 5:01 pm

    [...] Capture and Redirect HTTP to HTTPS with SharePoint 2007 (tags: sharepoint ssl) [...]

  12. Sam August 4th, 2009 12:05 pm

    Thanks for the nice solution. It works for me. But after applying this solution, I came across another issue. Actually I have a windows based wss site on Port 80 and I have mapped the drive to this site.so users can share the drive with sharepoint document library. As per your solution, I have changed the port from 80 to 8001 and assigned the 80 port to the new IIS site. But after making these changes, my mapping functionality stops working. So I would really appreciate if you find out any solution for this.

  13. david coello September 15th, 2009 10:37 am

    that was a great solutions thanks. also add the alternative mapping in sharepoint, that will also help a bit

  14. niky October 19th, 2009 5:37 am

    But now is searching unuseable with search engine in MOSS. Because all items in search points to http… instead to https..Does anyone know for this solution too ?

  15. viiin December 15th, 2009 12:13 am

    @nicky Same problem here, temp solution is if you have a firewall before the Sharepoint server you can force the HTTPS redirect and this will not affect WSSIndexer from the inside.

  16. [...] I searched online and found after a little digging this helpful article from a SharePoint blog at http://www.os.com/blog/capture-and-redirect-http-to-https-with-sharepoint-2007/. Here’s the crux of [...]

  17. Change to https March 2nd, 2010 8:20 am

    [...] link here Capture and Redirect HTTP to HTTPS with SharePoint 2007 Tech Tips, News and Tribal Knowledge [...]

Leave a reply

Subscribe without commenting