Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you just want to redirect based on the currently used protocol (as per your last sample) then there's a much simpler solution that will halve the amount of rules you will need. The following is what I've learned from a collegue of mine.</p> <p>As you've seen, the {HTTPS} argument will contain the value ON or OFF. You can map this value to https:// or http:// by feeding this value into a rewritemap.</p> <p>Here's how this would work:</p> <p>1- Create a rewritemap section for mapping the {HTTPS} value:</p> <pre><code> &lt;rewriteMap name="MapProtocol" defaultValue="OFF"&gt; &lt;add key="ON" value="https://" /&gt; &lt;add key="OFF" value="http://" /&gt; &lt;/rewriteMap&gt; </code></pre> <p>It's up to you to decide if you want to only include the protocol, or the semicolon and forward slashes as well. It doesn't matter for the solution, but keep it in mind wherever you refer to it.</p> <p>2- Refer to this map wherever you need. In this sample it's used in outbound-rules, but it'll also work in your scenario:</p> <pre><code> &lt;rule name="Outbound-Rule Name" stopProcessing="true" preCondition="ResponseIsHtml"&gt; &lt;match filterByTags="A, Link, Script" pattern="YOUR PATTERN" /&gt; &lt;action type="Rewrite" value="{MapProtocol:{HTTPS}}{HTTP_HOST}/REST OF RELATIVE LINK HERE" /&gt; &lt;/rule&gt; </code></pre> <p>That's it, the URL Rewrite module should now automagically use the correct protocol for your links depending on if you're using https, or, of course, http.</p> <p>Hope this helps!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload