Remove trailing slash from URL in Umbraco

A common issue with Umbraco is that front end URL's are available both with and without the trailing slash i.e.

Although they are the same page, Google will see this as duplicate content and derank accordingly - what we need it a way to force Umbraco to remove the trailing slash.

There is a setting in the UmbracoSettings.Config file to add a trailing slash:

    <!-- this will add a trailing slash (/) to urls when in directory url mode -->

But this does not really work for us in this situation - you can still access both url's (particularly in a multi domain site as was in my case)

The trick is to use the URL redirect rule shown below.
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
		<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
		<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<action type="Redirect" redirectType="Permanent" url="{R:1}" />

Need an Umbraco Master?

Here at Simon Antony, we have an in house certified Umbraco Grand Master available for hire. Got a problem with your site, need architecture advice, give us a call to speak to Simon directly and see how we can help

Contact Simon Today!