Link to home
Start Free TrialLog in
Avatar of bemara57
bemara57

asked on

Redirect to SSL using IIS7 UrlRewrite

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

ASKER CERTIFIED SOLUTION
Avatar of cj_1969
cj_1969
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
>> 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.