You are here: Sysadmins of the North » Web applications » Umbraco » How to add a trailing slash in Umbraco 8

How to add a trailing slash in Umbraco 8

This article shows you how to add a trailing slash to URL’s in Umbraco 8, using IIS URL Rewrite Module, without breaking the Umbraco backend. Forcing one particular URL avoids duplicate content, which is important for SEO.

Explicitly adding a trailing slash to Umbraco 8 URL’s, or removing the trailing slash, is an important step in avoiding duplicate content on your site. Duplicate content refers to having the same content on different domains or URL’s. Avoiding this is important for the SEO of your web site. And here is how you can add a trailing slash in Umbraco 8.

First, to add a trailing slash to Umbraco URL’s, you first need to edit your site’s ~/Config/umbracoSettings.config file. Look up the key requestHandler, and add:

<addTrailingSlash>true</addTrailingSlash>Code language: HTML, XML (xml)

Next you open your web.config file, and you need to add some URL Rewrite Module rewrite rules. Look up:

-->Code language: HTML, XML (xml)

Remove the comment markers and add between <rules></rules>:

<rule name="Add trailing slash in Umbraco URL" stopProcessing="true">
	<match url="(.*[^/])$" />
		<add input="{REQUEST_URI}" negate="true" pattern="^/(umbraco|DependencyHandler\.axd)" />
		<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
		<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
	<action type="Redirect" redirectType="Permanent" url="{R:1}/" />

</rule>Code language: HTML, XML (xml)

It is important to exclude DependencyHandler.axd from rewriting (line 4), because HTTP requests fail if they contain /DependencyHandler.axd/.

Upload both files and restart your Umbraco web application. This is all that’s needed to force a trailing slash in Umbraco.

Why is duplicate content bad?

Duplicate content confuses Google and forces the search engine to choose which of the identical pages it should rank in the top results. Regardless of who produced the content, there is a high possibility that the original page will not be the one chosen for the top search results.

Is an URL containing a trailing slash faster to load?

In the old days, some argued an URL with a trailing slash was faster to load, because it was treated as a directory by the web server and it didn’t have to look for a file with that name. I guess that nowadays web servers (RAM and NVME SDD storage included) are so fast that there is hardly any performance gain.

But it’s still important to choose an URL scheme: with or without trailing slash.

Are you looking for rock solid, eco-friendly, Umbraco hosting? Look no further! UmbHost is an Umbraco Registered Partner offering hosting services for websites and businesses of all sizes.

Show Your Support

donate with Paypal

If you want to step in to help me cover the costs for running this website, that would be awesome. Just use this link to donate a cup of coffee ☕($10 USD or €10 EUR for example). And please share the love and help others make use of this website. Thank you very much! <3 ❤️

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top