Reputation: 14586
I can't figure out how to solve this problem with url rewriting:
urls following this pattern
app/(.*)
should be redirected to app/index.cshtml
However the app folder contains resources such as sub-folders, js files and html files. These should be ignored an no redirection should be done.
Here's how Ive done it :
<rewrite>
<rules>
<rule name="Rule 1" stopProcessing="true">
<match url="app/(.*/.js)" />
<action type="None" />
</rule>
<rule name="Rule 2">
<match url="app/(.*)" />
<action type="Rewrite" url="app/index.cshtml" />
</rule>
</rules>
</rewrite>
I've only tried to exclude js files for now, but when I browse to app/someurl, I get an error because one of the js files cannot be loaded. I think that's because the first rule does not work.
Can you help ?
Upvotes: 1
Views: 965
Reputation: 14586
This is what I ended up doing :
<rule name="Rule1">
<match url="(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" negate="true" pattern="\.axd$" />
<add input="{URL}" negate="true" pattern="\.jpg$" />
<add input="{URL}" negate="true" pattern="\.gif$" />
<add input="{URL}" negate="true" pattern="\.png$" />
<add input="{URL}" negate="true" pattern="\.css$" />
<add input="{URL}" negate="true" pattern="\.ico$" />
<add input="{URL}" negate="true" pattern="\.cur$" />
<add input="{URL}" negate="true" pattern="\.js$" />
<add input="{URL}" negate="true" pattern="\.xml$" />
<add input="{URL}" negate="true" pattern="\.svg$" />
<add input="{URL}" negate="true" pattern="\.ttf$" />
<add input="{URL}" negate="true" pattern="\.eot$" />
<add input="{URL}" negate="true" pattern="\.woff$" />
<add input="{URL}" negate="true" pattern="\.html$" />
</conditions>
<action type="Rewrite" url="app/index.cshtml" />
</rule>
Upvotes: 2