Trailing slashes in Orchard

Up until about 20 minutes ago, viewing this blog via would work, but viewing it via 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 = "(.*)/$" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input = "{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <action type = "Redirect" url="{R:1}" />

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