Reputation: 5176
With IIS7, URL Rewrite 2 there is an MVC4 application APP on server SRV. The following rewrite should happen.
http://SRV/APP into http://SRV/APP/
I tried by creating the AddTrailingSlash rule. However, it does not work for the application's root. It does work for directories under the root, so the following rewrite is done
http://SRV/APP/pipapo into http://SRV/APP/pipapo/
What has to be done so the rewrite also works for the root?
Upvotes: 3
Views: 924
Reputation: 1
By default, the built in add trailing slash does not apply to directories or filenames... If you want it to apply to directories (like in the above example http(s)://srv/app), you have to modify the rule and delete the Condition that has "Type: Is Not a Directory". Don't forget to apply...
Happy URL Rewriting! :)
Upvotes: 0
Reputation: 12223
The following rule seems to work for me:
<!--Add trailing slash to root non-file url-->
<rule name="Add trailing slash" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<!--Match uri's missing trailing slash-->
<add input="{PATH_INFO}" pattern="(.*[^/])$" />
<!--Ignore any uri containing a period (probably a better way to do this but IsFile was not behaving as expected for me)-->
<add input="{PATH_INFO}" pattern="(.*?)\.(.*?)" negate="true"/>
</conditions>
<action type="Redirect" redirectType="Permanent" url="{PATH_INFO}/" />
</rule>
Upvotes: 1