• Home /
  • Blog /
  • How to remove trailing slash in Umbraco 8
Umbraco 8 Trailing Slash

How to remove trailing slash in Umbraco 8

When you work with Umbraco 8, you want the same style for all your URLs. In some cases, you want them ends with the trailing slash, like this: https://www.yaplex.com/blog/, and that is a default Umbraco 8 behavior.

In some cases, you prefer no slash, like this: https://yaplex.com/blog, and in this case, you need a little configuration done for your website.

Umbraco 8 settings to handle trailing slash

Firstly you need to update umbracoSettings.config and add the following to the requestHandler section.

  <requestHandler>
    <addTrailingSlash>false</addTrailingSlash>
  </requestHandler>

That instructs Umbraco 8 to stop adding a trailing slash to all your URLs, and after you make the changes, all your links will look fine.

But that is not enough, because now your pages are available under two URL, first with the slash at the end and second without.

IIS rewrite rule to fix trailing slash in Umbraco

To fix this, you need IIS rewrite rule, which will 301 redirect all incorrect URLs to the correct version.

Just and the following rule to your web.config, and the issue is solved.

  <rule name="Remove trailing slash" stopProcessing="true">
    <match url="(.*)/$" />
    <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Redirect" redirectType="Permanent" url="{R:1}" />
  </rule>
Yaplex - Freelance developer - white logo on black background

Yaplex ® is a custom software development company located in Mississauga, Ontario. Yaplex was founded in 2013 and provides website development, mobile development, and custom .NET software development services.

Contact Information

Mississauga, ON, Canada
Phone: +1 647 328 3809
Email: hello@yaplex.com