Solved

Redirect to SSL using IIS7 UrlRewrite

Posted on 2009-06-30
4
979 Views
Last Modified: 2013-11-08
I am using IIS7's new UrlRewrite engine (http://learn.iis.net/page.aspx/460/using-url-rewrite-module/). I want to redirect certain pages to an SSL page, and keep other pages off SSL for unneccessary encryption processing.

So far I have the redirect to SSL rule started, but it is not working. I am trying to keep a list of secure pages in the rewritemaps for easy maintenance and adding more secure pages in the future. Does anyone see why this is not working?
<rules>

	<rule name="RequiresSSL-Redirect" stopProcessing="true">

		<match url="(.+)" />

		<conditions>

			<add input="{HTTPS}" pattern="off" />

			<add input="{RequiresSSL:{R:1}}" pattern="(.+)" />

		</conditions>

		<action type="Redirect" url="https://{HTTP_HOST}/{C:1}" appendQueryString="true" redirectType="Permanent" />

	</rule>

</rules>

<rewriteMaps>

	<rewriteMap name="RequiresSSL">

		<add key="path/to/secure/page.aspx" value="path/to/secure/page.aspx" />

		<add key="nextpath/to/secure/page.aspx" value="nextpath/to/secure/page.aspx" />

	</rewriteMap>

</rewriteMaps>

Open in new window

0
Comment
Question by:bemara57
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
cj_1969 earned 500 total points
ID: 24754874
You might want to try this ... http://www.codescene.com/2006/03/redirecting-http-to-https-usin.php

The method here is that you just enable the SSL required for the pages that require it and then let the built-in error pages handle the redirection for you by customizing the 403.4 error code for the site or specific sub-site or directory.  I have used this in the past and it works well.  You can do this for an entire site, just make the entire site SSL required and remove the requirement for this one redirect page.
0
 
LVL 22

Expert Comment

by:cj_1969
ID: 24754918
If you want to use the rewrite capability then check out this page ... http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/

It has rules for a number of common rewrite situations, including http to https.
0
 
LVL 37

Expert Comment

by:meverest
ID: 24755823
>> So far I have the redirect to SSL rule started, but it is not working.

what is happening that is different to what you expect?  Does it throw an error or does it not switch to ssl when you think it should?

Cheers.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Determine Server Specs for IIS.7 Website 4 33
C# Offline Apllication 5 48
Syntax Error 2 41
Run time Error 4 34
Imagine a situation that you have installed SSL (http://en.wikipedia.org/wiki/Secure_Sockets_Layer) Certificate on your Cisco ASA (Cisco Adaptive Security Appliance) firewall. Installation of SSL certificate on ASA is an another topic for which you …
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now