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.
<!– begin hide
var oldURL = window.location.hostname + window.location.pathname;
var newURL = “https://” + oldURL;
window.location = newURL;
// end hide –>
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.