Kode
Kode

Reputation: 3215

IIS URL Rewrite Rule Excluding Multiple Files

I have an IIS URL Rewrite rule that forces HTTPS unless that page is a healthcheck.html (which is over port 80). This works like a charm as I use the match URL logic as follows:

<match url="healthcheck.html" negate="true" />

However, I need to exclude not just this page but a second file named OtherCheck.aspx in a directory named Dir1

I have not found any instances where others have excluded two files, especially one that is not in the root. Is it possible to have two filename exclusions? I tried this but it did not work:

<match url="healthcheck.html&/Dir1/OtherCheck.aspx" negate="true" />

Upvotes: 0

Views: 285

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12759

File and folder structure: s1(root folder):

healthcheck.html(file)

s2(subfolder):

page1.html(file)

You could use below url rewrite rule to exclude multiple files:

 <rule name="Redirect to HTTPS multiple file" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTPS}" pattern="off" />
                    <add input="{REQUEST_URI}" pattern="^/healthcheck.html" negate="true" />
                    <add input="{REQUEST_URI}" pattern="^/s2/page1.html" negate="true" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
   </rule>

https redirect:

enter image description here

exclude file: enter image description here enter image description here

Note: You could set file and folder name as per your requirement.

Regards, Jalpa

Upvotes: 2

Related Questions