0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
JPPINTO
  • Home
  • Certifications
  • About
  • Contact
  • Gallery
  • Current Setup
Contact

Search

January 17, 2009 / IIS 6.0

Automatically Redirect HTTP requests to HTTPS on IIS 6

Tags: http redirect, https, https redirect, IIS, redirect http to https

This article is for IIS 6 for the IIS 7 please refer to this article.

If you configure IIS to only allow https connections, a user will get a 403.4 error when attempting to access the page via http. To fix this problem we create a custom 403.4 page that redirects http requests to https. We will be changing this configuration in a couple of steps:

Step 1 – Verify SSL is required for the selected site
Step 2 – Create a HttpRedirect.htm file and save it to C:InetPub
Step 3 – Set the 403.4 error page to use this file instead of the regular error file
Step 4 – Test

This is a standard 403.4 error message file provided out of the box with IIS.

Step 1 – Verify SSL is required for the selected site

1)””””” Open IIS Manager (Start MenuProgramsAdministrative Tools or %SystemRoot%system32inetsrviis.msc)
2)””””” Expand the Computer Name
3)””””” Expand Web Sites
4)””””” Right click the web site we wish to modify
5)””””” Select “Properties”

6)””””” Select the “Directory Security” tab
7)””””” Select “Edit” in the Secure Communications section
8)””””” Check off the “Require secure channel (SSL)” option. (This will only allow pages on this site to be viewed only with https.)
9)””””” Press OK and close all Properties windows

Step 2 – Create a HttpRedirect.htm file and save it to C:InetPub

We will be creating an HTM file containing the following code. We will save this file to C:Inetpub.

1)””””” Open Notepad and copy in the following code below
2)””””” Go to File > Save as and save this file as HttpRedirect.htm, and save the file to C:Inetpub directory.

You can download a copy of this file here: HttpRedirect.zip

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

<script type="text/javascript">

function redirectToHttps()

{

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

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

window.location = httpsURL ;

}

redirectToHttps();

</script>

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

 

Step 3 – Set the 403 error page to use this file instead of the regular error file

1)””””” Expand the Computer Name
2)””””” Expand Web Sites
3)””””” Right click the web site you wish to modify
4)””””” Select “Properties”

5)””””” Select “Custom Errors” Tab
6)””””” Select the “403;4″ error
7)””””” Press the “Edit” button
8)””””” Browse to and Select the HttpRedirect.htm file in C:Inetpub
9)””””” Press OK and close all Properties windows

Step 4 – Test

1)””””” Bring up a web browser and try to access the site by https, verify that this is working ok
2)””””” Try to access the site via http now. You should see the browser change the http:// to https://

Note

In the unlikely event that a client does not have JavaScript enabled, this will not work. JavaScript must be enabled on the client machine for this to work.

Post Views: 1,537
<- Windows Server 2008 Standard Installation
Windows 7 Beta Installation ->

Categories

  • Active Directory (5)
  • Amazon Cloud Services (1)
  • Blazor (1)
  • C# (C-Sharp) (3)
  • CI/CD Pipelines (1)
  • Containers (4)
  • Development (1)
  • Docker (3)
  • General (5)
  • IIS 6.0 (4)
  • IIS 7.0 (10)
  • IIS 8.0 (1)
  • Infrastructure as Code (IaC) (1)
  • Kubernetes (3)
  • MySQL (1)
  • Office 2010 (1)
  • PHP (1)
  • PowerShell (3)
  • SharePoint 2007 (8)
  • SharePoint 2010 (19)
  • SharePoint 2013 (2)
  • SMTP (4)
  • SQL Server 2008 (1)
  • SQL Server 2008 R2 (1)
  • SQL Server 2012 (2)
  • SQL Server 2019 (1)
  • Uncategorized (1)
  • URL Rewrite (2)
  • Visual Studio 2019 (1)
  • Visual Studio Code (1)
  • Windows 10 (2)
  • Windows 2003 (9)
  • Windows 2008 (18)
  • Windows 2012 (6)
  • Windows 7 (3)
  • Windows Firewall (1)
  • Windows Vista (1)

Recent Posts

  • Install Terraform on Windows
  • Create a .NET Core 3.1 Console App in Visual Studio Code
  • Install a stand-alone SQL Server 2019 Enterprise Server
  • Create a Blazor App project in Visual Studio 2019
  • Username and Password for minikube Virtual Machine

Advertisement

Tags

backconnectionhostnames custom column default gateway disappears disable shutdown event tracker error opening exe exe permissions externalize blob externalize sharepoint data facebook spam filezilla server firewall rules filazilla full installation http redirect https https redirect IIS iis7 iis 7 installation IIS installation index server configuration installing cumulative updates load balance central administration magic default gateway missing default gateway moss advanced search nlb no default gateway powershell redirect http to https search column sharepoint 2010 cumulative updates sharepoint 2010 farm build sharepoint 2010 farm configuration sharepoint 2010 farm installation sharepoint data externalization shutdown event tracker shutdown tracker SMTP storagepoint Windows 7 windows firewall configuration windows live messenger crash windows server 2008 wlbs x86
© 2026 JPPinto.com – Tech Blog. All rights reserved.