troubleshooting Question

Issue with redirecting from http to https on iis and windows 2003

Avatar of semperfi89
semperfi89 asked on
Microsoft IIS Web ServerSSL / HTTPS
19 Comments1 Solution393 ViewsLast Modified:
I'm currently using the attached code to redirect from http to https,

This has been fine for a number of years, but now I've started hosting another site on the same server and IIS will not allow both sites to use port 443 for https.   So I need to be able to redirect the site to the non standard port I setup for the second site (444).  The issue I have is that I do not want to have several versions of this file with the ssl port hard coded into it.  I would like a solution that will query the server for the ssl port and then redirect to that port.

If Request.ServerVariables("SERVER_PORT")=80 Then
         Dim strQUERY_STRING
         Dim strSecureURL
         Dim strWork

         ' Get server variables
         strQUERY_STRING = Request.ServerVariables("QUERY_STRING")

         ' Fix the query string:
         strWork = Replace(strQUERY_STRING,"http","https")
         strWork = Replace(strWork,"403;","")
	 strWork = Replace(strWork,":80","")

         ' Now, set the new, secure URL:
         strSecureURL = strWork
'response.write(strSecureURL) ' uncomment for sanity check.
         Response.Redirect strSecureURL
     End If

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 19 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros