This project is read-only.


Core Routing engine not properly handling trailing / for URLs


Our clients are complaining. There's times where URLs, for whatever reason, have trailing '/'. They should not 404.

Orchard sites: - works - 404 - works - 404

Non-Orchard sites: - works - works - works - works

I don't think it's realistic to expect rewrite rules to cover every URL or URL pattern to handle trailing slash. The default behavior should be to simply ignore the trailing slash and load the page as if it wasn't added. Please fix.
Closed Apr 23, 2013 at 7:19 AM by BertrandLeRoy
See comments


pszmyd wrote Apr 23, 2013 at 1:05 AM

A workaround would be to add a rewrite rule to rewrite or 301 redirect URLs with trailing slash to the one without it.

morrisonbrett wrote Apr 23, 2013 at 1:06 AM

@Pszmyd - that's not an acceptable workaround for us.

morrisonbrett wrote Apr 23, 2013 at 1:38 AM

Well we could add a rewrite rule but I wonder if it should be in Core. Thoughts?

<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<action type="Redirect" redirectType="Permanent" url="{R:1}" />

BertrandLeRoy wrote Apr 23, 2013 at 2:09 AM

Why is it not an acceptable workaround?

BertrandLeRoy wrote Apr 23, 2013 at 2:10 AM

Including that rewrite rule in core doesn't seem possible, as rewrite is an optional IIS module. Furthermore, which of the two conventions do we make canonical? With or without the slash?

BertrandLeRoy wrote Apr 23, 2013 at 7:19 AM

Additional reasons this shouldn't be in core:
This is the standard MVC behavior. You may have different resources behind both URLs. Search engines will actually treat them differently. Here is an excellent link provided by Piotr that explains it well: