Tuesday, December 18, 2018

IIS Redirect rule



in web.config in <system.webServer> add the following after  </httpProtocol>:

<rewrite>
      <rules configSource="RedirectRules.config"></rules>
    </rewrite>

and in the RedirctRules.config (which is place in the same location where web.config is)

<rules>
  <rule name="redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="redirect" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="/*scwww-st.net" />
</conditions>
<action type="Redirect" url="/healthcare-professionals/or-staff/for-or-staff" logRewrittenUrl="true" redirectType="Permanent" />
  </rule>
<rule name="Base Url" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
<add input="{REQUEST_URI}" pattern="/" />
</conditions>
<action type="Redirect" url="http://intuitivesurgical.dev.local/en-us" />
</rule>
<rule name="Base en Url" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
<add input="{REQUEST_URI}" pattern="/en" />
</conditions>
<action type="Redirect" url="http://intuitivesurgical.dev.local/en-us" />
</rule>
<rule name="rule1">
<match url="(.*)" />
            <conditions>
                <add input="{REQUEST_URI}" pattern="(.*)/en/(.*)" />
            </conditions>
<action type="Redirect" url="{C:1}/en-us/{C:2}" />
</rule>
 </rules>

============================================


<rules>
  <rule name="redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="redirect" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="/*scwww-st.net" />
</conditions>
<action type="Redirect" url="/healthcare-professionals/or-staff/for-or-staff" logRewrittenUrl="true" redirectType="Permanent" />
  </rule>
    <rule name="ISI" patternSyntax="Wildcard" stopProcessing="true">
        <match url="*" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
            <add input="{REQUEST_URI}" pattern="/" />
        </conditions>
        <action type="Redirect" url="http://intuitivesurgical.dev.local/en-us" />
    </rule>
 </rules>


The one below would replace hostname/en with hostname/en-us
and
any url with /en/ in ti to /en-us/

<rule name="Base en Url" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
<add input="{REQUEST_URI}" pattern="/en" />
</conditions>
<action type="Redirect" url="http://intuitivesurgical.dev.local/en-us" />
</rule>
<rule name="rule1">
<match url="(.*)" />
            <conditions>
                <add input="{REQUEST_URI}" pattern="(.*)/en/(.*)" />
            </conditions>
<action type="Redirect" url="{C:1}/en-us/{C:2}" />
</rule>



= ====== from Nalan

<rules>
  <rule name="Base Url" patternSyntax="Wildcard" stopProcessing="true">
  <match url="*" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
    <add input="{REQUEST_URI}" pattern="/" />
  </conditions>
  <action type="Redirect" url="http://intuitivesurgical.dev.local/en-us" />
</rule>
<rule name="Lowercase Canonical Url" enabled="true" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{URL}" pattern="[A-Z]" ignoreCase="false" />
  </conditions>
  <action type="Redirect" url="{ToLower:{URL}}" redirectType="Temporary" />
</rule>
<rule name="en Redirect" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="en/(.*)" />
  <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
  </conditions>
  <action type="Redirect" url="http://intuitivesurgical.dev.local/en-us{R:1}" />
</rule>
<rule name="en_us Redirect" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="en_us([./]?.*)" />
  <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="intuitivesurgical.dev.local" />
  </conditions>
  <action type="Redirect" url="http://intuitivesurgical.dev.local/en-us{R:1}" />
</rule>
<!--<rule name="Davinci Privacy policy" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="privacy-policy[./]?$" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="davincisurgery.dev.local" />
  </conditions>
  <action type="Rewrite" url="about-us/privacy-policy" logRewrittenUrl="true" />
</rule>-->
<rule name="About the davinci system" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
  <match url="about-da-vinci-systems[./]?$" />
  <conditions logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="davincisurgery.dev.local" />
  </conditions>
  <action type="Rewrite" url="da-vinci-systems/about-da-vinci-systems" logRewrittenUrl="true" />
</rule>
</rules>




or in IIS:

click on the site then double click "URL Rewrite"


No comments:

Post a Comment