Trailing slashes in Orchard

Up until about 20 minutes ago, viewing this blog via http://robertwray.co.uk/blog would work, but viewing it via http://robertwray.co.uk/blog/ wouldn't. Logical, no?

The solution is to add a redirect rule to either strip-off, or add-on the trailing slash:

<rule name = "Remove trailing slashes" stopProcessing="true">
    <match url = "(.*)/$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input = "{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    </conditions>
    <action type = "Redirect" url="{R:1}" />
</rule>

Be careful to make sure that all blogs that you've got configured (or anything else for that matter!) is expecting to respond to a URL that doesn't have a trailing slash - i.e. don't have one blog configured as "/blog" and another as "/recipes/" otherwise it'll all come a bit unstuck.


No Comments