Wrox Programmer Forums
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 19th, 2011, 10:32 PM
Authorized User
Join Date: Sep 2004
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
Default Forcing http to go to https

Good evening.

This is not really an asp question however my site is coded in asp, but here goes:

I'm about to implement https for my asp website; I use IIS 7 to serve it up.

I need to redirect all http hits to https. I know I can make this global change in IIS but that is insufficient. The reason is that my site generates hundreds of e-mails which go to my users and these e-mails contain hard-coded links back to many, many different pages on my site. When I switch over to https, my users will still reference the old e-mails with the old links and won't be able to access the web page unless there's a redirect.

Do you know how I can implement these redirects? Is there a change to my web.config file I can make? I've also been reading articles about htaccess redirect but it seems this is not iis friendly.

Any help you can provide would be appreciated.

Thank you!

Old June 3rd, 2011, 01:44 AM
Registered User
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hello Sal,

Please keep the below code in top of all pages , it will redirect from http to https.

IF Request.ServerVariables("HTTPS")="off" THEN
IF LEN(Request.ServerVariables("QUERY_STRING"))>0 THEN
 Response.Redirect "https://" + Request.ServerVariables("SERVER_NAME")+   Request.ServerVariables("URL")+"?"+Request.ServerVariables("QUERY_STRING")

 Response.Redirect "https://" + Request.ServerVariables("SERVER_NAME")+  Request.ServerVariables("URL")
Thank you,
Old June 10th, 2011, 04:14 PM
Authorized User
Join Date: Sep 2004
Posts: 68
Thanks: 1
Thanked 0 Times in 0 Posts
Default thank you!

thank you!

Similar Threads
Thread Thread Starter Forum Replies Last Post
migrating http to https RoniR ASP.NET 1.0 and 1.1 Professional 15 April 27th, 2007 01:27 PM
Returning from HTTP to HTTPS techy Classic ASP Basics 2 September 27th, 2006 12:12 PM
How does one switch from HTTP to HTTPS Aaron Edwards Classic ASP Basics 0 September 29th, 2005 10:32 AM
Passing login state across http and https astra Classic ASP Basics 0 May 19th, 2004 05:19 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.