URL Rewrite update protocol and domain if URL is http://

I would like to redirect all calls to http://www.domain.com/csp/ to https://secure.doman.com/csp/ using URL rewrite running on IIS 8.5. I would like the URL on the browser to update accordingly. I cannot get it to work.

Below is the section of the web.config file with the rule

    <rule name="CSP to SSL" enabled="true" stopProcessing="true">
       <match url="^http://www.domain.com/csp/(.*)$" />
                    <add input="{CACHE_URL}" pattern="^http://" />
       <action type="Redirect" url="https://secure.domain.com/csp/{R:1}" />

Thank you.


Thanks to peterviola's reply at http://forums.iis.net/t/1214515.aspx?Change+to+https+and+adjust+domain+if+URL+uses+http+and+matches+a+particular+path I managed to get to the solution I was seeking.

           <rule name="csp2HTTPS" enabled="true" stopProcessing="true">
                <match url="(.*)csp/(.*$)" ignoreCase="true" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" />
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />
            <rule name="csp2subdomain" enabled="true" stopProcessing="true">
                <match url="(.*)csp/(.*$)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="^(www.|)domain.com$" />
                <action type="Redirect" url="https://secure.domain.com{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />

The above solution works. I can't understand why this could not be done using one rule.

Hope this helps.

Need Your Help

returns the first n of list

list scheme

How to return the first n elements of a list? Here's what I have:

Django Form Fields based on Model Choices

django forms models

I want to offer form fields based on model choices. So, if in my models:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.