How to add trailing slashes to the end of a CraftCMS URI

Oscar de la Hera Gomez
Two flowers that represent CraftCMS and DDEV side by side. Beneath them sits the text "Trailing Slashes in URI/URL."

A step by step guide to adding trailing slashes to the end of a URI/URL.

A screenshot of CraftCMS showing how if you hover over a URI, there is no trailing slash.

The following tutorial demonstrates how to add a trailing slash to the end of a URI/URL in CraftCMS.

We would like to thank the support team at CraftCMS for giving us the tip of how to do this.

Step One: Update the CraftCMS Config

A screenshot of VSCode showing how to add trailing slashes to the CraftCMS URI through the general.php config file.

In the general.php file of your CraftCMS codebase, add the following line:

->addTrailingSlashesToUrls(true)

Step Two: Check

A screenshot of CraftCMS showing how the URI/URL now has a trailing slash.

Refresh the browser and check that the URI now adds a trailing slash to the URI/URL in your development environment.

Step Three: Deploy

A screenshot of a hosted CraftCMS that shows that the URI now adds the trailing slash.

Deploy the change and confirm that it appears on your hosted CraftCMS.

Looking to learn more about CraftCMS?

Search our blog to see the rest of our tutorials on CraftCMS.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details