Reputation: 813
I'm relatively new to IIS Rewrite Rules so forgive me if this is not actually feasible in IIS Rewrite.
I'm trying to setup a 'fallback' route for some static content on a site. I always have the root content, but not necessarily the slug-path. E.g.
http://example.com/some-slug/foo.js
If /some-slug/foo.js
doesnt exist, I want to fall back to /foo.js
on the root of the site, and serve this as the response.
Is this achievable in IIS re-write?
Upvotes: 1
Views: 729
Reputation: 5677
Yes it is achievable
<rewrite>
<rules>
<rule name="rewritewithfallback">
<match url="some-slug/(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}" />
</rule>
</rules>
</rewrite>
Upvotes: 3