Category: IIS

IIS 6 Http to Https Redirect

Yes, why on earth would you still be using a server which can only support IIS6?! But somethings in this world cannot be pushed into the future fast enough, in the case of our organisation there are quite a few Windows 2003 servers which are still in use, which is shocking.

So what do I need to do to get a redirect in place?

Create a blank file called HttpRedirect.htm in the directory root of your website, copy in the below code.

<!-- beginning of HttpRedirect.htm file -->

<script type="text/javascript">

function redirectToHttps()


var httpsPort = ":4443"

<!-- Add +httpsPort after the window.location.hostname if the standard https port is not 443 -->

var httpURL = window.location.hostname+window.location.pathname;

var httpsURL = "https://" + httpURL ;

window.location = httpsURL ;




<!-- end of HttpRedirect.htm file -->

Set the 403.4 error page to use this file instead of the regular error file. Do this in IIS6, right click and select ‘Properties‘ on your website, click on ‘Custom Errors‘ tab, find 403.4 in the list click ‘Edit‘ and ‘Browse‘ point it at the file which you created above.

Select the ‘Directory Security‘ tab, select ‘Edit’ in the Secure Communications section

Check on the ‘Require secure channel (SSL)‘ option. (This will only allow pages on this site to be viewed only with Https.)

Now browse to a URL on this website and your be redirect from http to https.

IIS Redirect HTTP to HTTPS

We needed to redirect from HTTP to HTTPS as some of our sites weren’t yet updated to cope with HTTPS
So instead of doing it for all sites on our IIS server we needed to do it for one to start with and leave the others intact.

This is how we did that.

First thing you need is a IIS module which isnt installed as standard, URL Rewrite. Instead of just clicking the large green button which Microsoft would like you to do, scroll down and download just the file version that you need.

Once you’ve installed this, you will need to restart your IIS on that server, we have 3 which are load balanced, so had to install this module on all 3 and restart all 3 in order to see the icon.

Hopefully Microsoft wont say you need to reboot the machine in order to install this, if you do get this message then you don’t have much choice apart from do what it is saying.

Okay, now launch the ‘URL Rewrite‘ module and do the following:

Add Rule(s)…‘ then select ‘Blank Rule‘.

Fill out the following as in the following screen, under ‘Match URL‘:


The regular expression is as follows:


Where ‘resultsonline‘ replace this with the name of application you want to jump to HTTPS

A break down of the what the above regular expression is doing:

^ = The match must start at the beginning of the string or line.
$ = Match must occur at the end of the string
| = Matches any one element separated by the vertical bar
/.+$ = / is just a slash . means Any + one or more $ end of the line, so it has to equal “/something” rather than /.* would match “/” or “/something”

In the ‘Conditions‘ section, click ‘Add…‘ and enter:


Then in the ‘Action‘ section, change the setting to:


Click ‘Apply‘ to save the rule.

Include the above with a binding for HTTPS and will redirect to

If you want to redirect all your sites from HTTP to HTTPS then just change the regular expression to (.*)

Hope it helps.

Problems with IIS 7?

Are you pretty certain that you’re settings are correct within IIS7, but it’s still not playing ball?

Then try rebooting your server.

Yes I know this is a very drastic measure – but this was the only thing that worked for me.

Things you could check before is the Up Time of the server, in my case I’m using ‘Windows Server 2008 R2’ view this in your ‘Windows Task Manager’ under the ‘Performance’ tab.
My server was denying me access to a SQL server with the following error; which I knew existed and worked when using a local version:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.

I’m sure that having my server running for over a 150 days had caused it to get itself in to a tizz, with updates that had been installed but not running etc.