<p>Try to add your alias array within one of your environment array such as:</p>
<pre class="lang-php prettyprint-override"><code>&lt;?php

return [
    // Global settings
    '*' =&gt; [
        'aliases' =&gt; [
            '@rootUrl' =&gt; getenv('ROOT_URL'),
        ],
    ],

    // Dev environment settings
    'dev' =&gt; [
        // ...
    ],

    // Staging environment settings
    'staging' =&gt; [
        // ...
    ],

    // Production environment settings
    'production' =&gt; [
        // ...
    ],
];

</code></pre>

CC BY-SA 4.0
2021-02-04T07:09:14.940Z
2021-02-04T07:09:14.940Z
Oli
<p>I'm trying to setup <strong>aliases</strong> following the <a href="https://craftcms.com/docs/3.x/config/#control-panel-settings" rel="nofollow noreferrer">instructions in the docs</a>, but I can't get them to work (for example they don't appear when setting paths for Assets).</p>
<p>I copied and pasted the code exactly as the example in the docs, and the <strong>env</strong> variable <code>ROOT_URL</code> shows up in the CP, but the <strong>alias</strong> <code>@rootUrl</code> does not. Is there another step? I tried clearing caches and logging out/in, but that didn't help.</p>
<p>In the <em>config/general.php</em> file I pasted the code last, right below Dev environment settings. Here is that last portion of the config:</p>
<pre><code>    // Dev environment settings
        'dev' =&gt; [
            // existing settings ...
            'backupCommand' =&gt; getenv('BACKUP_COMMAND'),
            'restoreCommand' =&gt; getenv('RESTORE_COMMAND'),
        ],

    // -- config/general.php Code example from docs --
        'aliases' =&gt; [
            '@rootUrl' =&gt; getenv('ROOT_URL'),
        ],
];
</code></pre>
<p>Also, the <a href="https://craftcms.com/knowledge-base/upgrading-to-craft-3-6#deprecated-config-settings" rel="nofollow noreferrer">3.6 upgrade documentation</a> states (emphasis mine):</p>
<blockquote>
<p>The siteName and siteUrl config settings have been deprecated. We strongly recommend you set your sites’ names and URLs using <strong>environment variables</strong> instead.</p>
</blockquote>
<p>So, does this mean I shouldn't even be bothering with aliases? Should everything be an environment variable only?</p>

<config><setup>
Custom Aliases not working
# Custom Aliases not working

(Asked by: username_0 on 2021-02-03)

I'm trying to setup aliases following the instructions in the docs, but I can't get them to work (for example they don't appear when setting paths for Assets).
I copied and pasted the code exactly as the example in the docs, and the env variable ROOT_URL shows up in the CP, but the alias @rootUrl does not. Is there another step? I tried clearing caches and logging out/in, but that didn't help.
In the config/general.php file I pasted the code last, right below Dev environment settings. Here is that last portion of the config:
    // Dev environment settings
        'dev' => [
            // existing settings ...
            'backupCommand' => getenv('BACKUP_COMMAND'),
            'restoreCommand' => getenv('RESTORE_COMMAND'),
        ],

    // -- config/general.php Code example from docs --
        'aliases' => [
            '@rootUrl' => getenv('ROOT_URL'),
        ],
];

Also, the 3.6 upgrade documentation states (emphasis mine):

The siteName and siteUrl config settings have been deprecated. We strongly recommend you set your sites’ names and URLs using environment variables instead.

So, does this mean I shouldn't even be bothering with aliases? Should everything be an environment variable only?

**Tags:** config, setup


---

## 1 answers

### Answer by username_1 on 2021-02-04. Score: 3 | Accepted answer

Try to add your alias array within one of your environment array such as:
 [
        'aliases' => [
            '@rootUrl' => getenv('ROOT_URL'),
        ],
    ],

    // Dev environment settings
    'dev' => [
        // ...
    ],

    // Staging environment settings
    'staging' => [
        // ...
    ],

    // Production environment settings
    'production' => [
        // ...
    ],
];


---

