• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

Redirect http to https instead of give standard 403.4 error message

I have a web server that host nothing but https pages.  This is a windows 2003 IIS server.  As a result, if you attempt to access these pages using http, you recieve the 403.4 standard error page.  How do I redirect these pages to https automatically instead of giving the 403.4 error?
  • 5
  • 3
1 Solution
Make a index.html and use that as the default page. In that file you redirect the user to the correct page:

<title>Javascript version</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language=javascript>
if (document.URL.search("(URL of correct page)") == -1)
      window.location.href="http://(correct page)";
Wrong URL
securitythreatAuthor Commented:
This will cause issue within the page itself.  I have several pages and cannot redirect the single html files.  There is a way to redirect the error page.  I do this on my exchange server but cannot figure out how to do it on my regular iis server.
Its very simple:

1. In your Default web site properties, at Document tab, move up the "Default.asp" (or add it if needed).

2. Create a default.asp in your INETPUB\WWROOT directory containing the following 2 lines:

<%@ Language=VBScript %>
<%  Response.redirect("https://YOUR-SERVER-FQN/YOUR-PATH/YOUR-PAGE.EXT")  %>

Replace YOUR-SERVER-FQN by your server's fully qualified name (I mean, by example: server1.mydomain.com)

Replace YOUR-PATH by your page's path ( I mean, by example: https://server1.mydomain.com/exchweb/bin/auth/usa/...   This is optional if you dont have a deep path)

And finally replace YOUR-PAGE.EXT by your page name and extension. By example: logon.asp

This is the easiest way to do it without getting complicated coding jscript, vbscript, etc.

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

securitythreatAuthor Commented:
This will only work with one site.  There are two sites that this server is hosting.
securitythreatAuthor Commented:
It is my understanding that I have to edit the 403.4 page to make this work.  This is the article i had to follow for the exchange server http://support.microsoft.com/kb/839357
securitythreatAuthor Commented:
I think that this is what i'm searching for.. http://blog.opsan.com/archive/2005/04/17/395.aspx ...

what do yout think?
securitythreatAuthor Commented:
Here is what i'm thinking.. I create a directory for the redirect for each site then poing the 403.4 error page to it.  Inside will be a default.aspx file that will redirect to the https default.aspx file on that site.  However, I dont know the code to do the redirection.
That's a good way to do it... but I honestly prefer to do not touch the default 403 page (just my way to do my stuff :-)   )

You have 3 options now:
1. Use my "2-lines" way, but you need to create a default.asp file per site you hosting (of course repeat the steps 1 and 2 for each web site, and do it in  \inetpub\wwwroot\your-sitename)

2. Copy the code in http://blog.opsan.com/archive/2005/04/17/395.aspx and paste  and paste it into a "default.asp" page (again, one per site you host)

3. Do it as described in the blog   :-)

Don't forget to include this line at the begining of their code: "<%@ Language=VBScript %>", start the code block with "<%  ", and end the code block with " %>"

Hope this helps!
Your idea is good too... but instead to do an ASPX do an ASP page just for redirect. The code for redirect in ASP is in my first post.

ASP pages processor is lightweight than ASPX one... and considering that the only job it will do is to redirect, it is not necessary to use an ASPX

But anyway, the code to redirect in ASPX can be something like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As_
System.EventArgs) Handles MyBase.Load
End Sub

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now