I think you may have needed it in the passed, you want to prevent that users can access a website on port 80 but also want to prevent they got an error displayed. The script below is the solution for this issue, it will redirect the user to the https version of the website.

The script can be placed in the root of the webserver in case of IIS this is wwwroot.

redirect.htm (bron)

_<script language=&#8221;JavaScript&#8221;>__function goElseWhere()_

<!&#8211; begin hide


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

var newURL = &#8220;https://&#8221; + oldURL;

window.location = newURL;



_// end hide &#8211;>_


The last step is to configure IIS to display this page instead of the default error page.

First how to do this in IIS 6.

Start the IIS Manager and get the properties of the default website. Select the tab called Custom Errors _and search for _HTTP error 403.4 .

When found select it and push the edit button, this will open the following window.

Select browse and search for the file redirect.htm which you have placed in the root of IIS. Click on OK _to select the file and click on _OK again to close the window above. A warning will be displayed that this error is also used by other virtual directories/websites. Click on JOK and restart IIS.

To change the custom error in IIS 7 you must follow the steps below.

Open the IIS Manager _and select the _Default Website, in the right part of the manager several icons are displayed.

Select the icon Error Pages, an overview of default error pages will be displayed. Right click somewhere on the white space en select add. The following window will be displayed.

Fill in the fields as specified below:

  • status code: 403.4
  • file path: %systemroot%\Inetpub\wwwroot\redirect.htm

Clickon OK _and restart _IIS.

When visiting the site http://webmail.domein.nl you will get redirected to https://webmail.domein.nl.


Johan Veldhuis