<p>The only thing <a href="https://craftcms.com/docs/4.x/config/general.html#addtrailingslashestourls" rel="nofollow noreferrer"><code>addTrailingSlashesToUrls</code></a> does, is to ensure that any and all URLs generated by Craft have trailing slashes added to them.</p>
<p>To redirect incoming requests without trailing slashes, you'll need to set up your own redirects (ideally this should happen at the web server level, i.e. in your Nginx config, Apache <code>.htaccess</code> file or the like).</p>

CC BY-SA 4.0
2022-11-01T13:08:16.323Z
2022-11-01T13:08:16.323Z
Mats Mikkel Rummelhoff
<p>I have set the <code>addTrailingSlashesToUrls</code> option in the config file <code>config/general.php</code> as below:</p>
<pre class="lang-php prettyprint-override"><code>&lt;?php
/**
 * General Configuration
 *
 * All of your system's general configuration settings go in here. You can see a
 * list of the available settings in vendor/craftcms/cms/src/config/GeneralConfig.php.
 *
 * @see \craft\config\GeneralConfig
 */

use craft\helpers\App;

return [
    // Global settings
    '*' =&gt; [
        // Default Week Start Day (0 = Sunday, 1 = Monday...)
        'defaultWeekStartDay' =&gt; 1,

        'enableTemplateCaching' =&gt; false,

        // Whether generated URLs should omit &quot;index.php&quot;
        'omitScriptNameInUrls' =&gt; true,

        // Control Panel trigger word
        'cpTrigger' =&gt; 'admin',

        // The secure key Craft will use for hashing and encrypting data
        'securityKey' =&gt; App::env('SECURITY_KEY'),

        // Whether to save the project config out to config/project.yaml
        // (see https://docs.craftcms.com/v3/project-config.html)
        'useProjectConfigFile' =&gt; false,

        'addTrailingSlashesToUrls' =&gt; true,
    ],

    // Dev environment settings
    'dev' =&gt; [
        // Dev Mode (see https://craftcms.com/guides/what-dev-mode-does)
        'devMode' =&gt; false,
    ],

    // Staging environment settings
    'staging' =&gt; [
        // Set this to `false` to prevent administrative changes from being made on staging
        'allowAdminChanges' =&gt; true,
    ],

    // Production environment settings
    'production' =&gt; [
        // Set this to `false` to prevent administrative changes from being made on production
        'allowAdminChanges' =&gt; true,
    ],
];
</code></pre>
<p>And now I expect to be able to visit <code>sitename.test/recipes</code> and have it redirect to <code>sitename.test/recipes/</code> but it doesn't.</p>
<p>Have I missed something?</p>

<craft3>
"addTrailingSlashesToUrls" Config option being ignored
# "addTrailingSlashesToUrls" Config option being ignored

(Asked by: username_0 on 2022-11-01)

I have set the addTrailingSlashesToUrls option in the config file config/general.php as below:
 [
        // Default Week Start Day (0 = Sunday, 1 = Monday...)
        'defaultWeekStartDay' => 1,

        'enableTemplateCaching' => false,

        // Whether generated URLs should omit "index.php"
        'omitScriptNameInUrls' => true,

        // Control Panel trigger word
        'cpTrigger' => 'admin',

        // The secure key Craft will use for hashing and encrypting data
        'securityKey' => App::env('SECURITY_KEY'),

        // Whether to save the project config out to config/project.yaml
        // (see https://docs.craftcms.com/v3/project-config.html)
        'useProjectConfigFile' => false,

        'addTrailingSlashesToUrls' => true,
    ],

    // Dev environment settings
    'dev' => [
        // Dev Mode (see https://craftcms.com/guides/what-dev-mode-does)
        'devMode' => false,
    ],

    // Staging environment settings
    'staging' => [
        // Set this to `false` to prevent administrative changes from being made on staging
        'allowAdminChanges' => true,
    ],

    // Production environment settings
    'production' => [
        // Set this to `false` to prevent administrative changes from being made on production
        'allowAdminChanges' => true,
    ],
];

And now I expect to be able to visit sitename.test/recipes and have it redirect to sitename.test/recipes/ but it doesn't.
Have I missed something?

**Tags:** craft3


---

## 1 answers

### Answer by username_1 on 2022-11-01. Score: 1 | Accepted answer

The only thing [`addTrailingSlashesToUrls`](https://craftcms.com/docs/4.x/config/general.html#addtrailingslashestourls) does, is to ensure that any and all URLs generated by Craft have trailing slashes added to them.

To redirect incoming requests without trailing slashes, you'll need to set up your own redirects (ideally this should happen at the web server level, i.e. in your Nginx config, Apache `.htaccess` file or the like).


---

