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.

About Rob

I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.

My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.

No Comments

Add a Comment