Mark
Mark

Reputation: 67

IIS URL Rewrite Module root directory mapping

I am using the URL Rewrite Module on IIS 8.

I want to be able to map all calls to *.archive to a page handler which does work using the following code

<rule name="Redirect .archive extension" stopProcessing="true">
          <match url="^(.*).archive" ignoreCase="true" />
          <conditions logicalGrouping="MatchAny">
            <add input="{URL}" pattern="(.*).archive$" ignoreCase="false" />
          </conditions>          
          <action type="Rewrite" url="PageHandler.ashx?path={C:1}" />
        </rule>

I now need to map calls to directories / paths to the same handler where a default file is not specified e.g.

https://www.example.com
https://www.example.com/images
https://www.example.com/images/

Does anyone have any example about how I can achieve the above and keep my archive rule?

Thanks Mark

Upvotes: 0

Views: 1092

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12759

You could use below rewrite rule:

 <rule name="Redirect .archive extension" stopProcessing="true">
      <match url="www.sample1.com/(.*)" ignoreCase="true" negate="true" />
      <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_URI}" pattern="(.*)" />
      </conditions>          
      <action type="Rewrite" url="page1.html?path={C:1}" appendQueryString="false" logRewrittenUrl="true" />
    </rule>

Note: Modify hostname and rewrite url as per your requirement.

enter image description here

enter image description here

Regards, Jalpa

Upvotes: 1

Related Questions