Note that there are some explanatory texts on larger screens.

plurals
  1. POIIS 7.5 Canonical URL Rewrite rules for multiple domains
    primarykey
    data
    text
    <p>In the context of <strong>URL Rewrite 2.0</strong> in <strong>IIS 7.5</strong>, I want to be able to enforce canonical domain names for multiple domains for a multi-country site, in as few rules as possible. Something like this:</p> <pre><code>&lt;rule name="UK Host Name"&gt; &lt;match url="(.*)" /&gt; &lt;conditions logicalGrouping="MatchAll"&gt; &lt;add input="{HTTP_HOST}" pattern="^company\.co\.uk$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^company\.co$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^company\.org$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^company\.net$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^company\.uk\.com$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^www\.company\.co\.uk$" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="http://www.company.co.uk/{R:1}" /&gt; &lt;/rule&gt; &lt;rule name="France Host Name"&gt; &lt;match url="(.*)" /&gt; &lt;conditions logicalGrouping="MatchAll"&gt; &lt;add input="{HTTP_HOST}" pattern="^company\.fr$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^company-france\.com$" /&gt; &lt;add input="{HTTP_HOST}" pattern="^www\.company\.fr$" negate="true" /&gt; &lt;/conditions&gt; &lt;action type="Redirect" url="http://www.company.fr/{R:1}" /&gt; &lt;/rule&gt; </code></pre> <p>The problem with the above, I believe, is that each of those conditions must be true hence <code>logicalGrouping="MatchAll"</code> but if changed to <code>MatchAny</code> then the last condition (with <code>negate="true"</code>) will be ignored, meaning we run the redirect rule even if the user is visiting the correct domain.</p> <p>The only alternative I can think of is having a separate rewrite rule for every single different domain, but there could be vast numbers of domains and it could get messy. There will be plenty of other rewrite rules and maps as it is.</p> <p><strong>How can I create more complex sets of conditions, rather than just All or Any?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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