Production siteUrl being used in staging environment I'm using the following multi-env config. My dev config works as expected. However, when I visit my staging site, it is setting the siteUrl to the production Url

    &lt;?php

    // Dev URL
    $devUrl_au  = "au-site.dev";
    $devUrl_nz  = "nz-site.dev";
    $devUrl_us  = "us-site.dev";

    // Testing URL
    $testUrl_au = "test.site.com.au";
    $testUrl_nz = "test.site.nz";
    $testUrl_us = "test.site.co";

    // Production URL
    $liveUrl_au  = "site.com.au";
    $liveUrl_nz  = "site.nz";
    $liveUrl_us = "site.co";

    return [
        /***************************
        GLOBAL CONFIGURATION
        ***************************/
        '*' =&gt; [
            'environmentVariables' =&gt; [
                'assetUrl'  =&gt; '/',
            ],
            'doAnalytics' =&gt; false,
            'omitScriptNameInUrls' =&gt; 'auto',
            'enableCsrfProtection' =&gt; true,
        'siteRoutesSource' =&gt; 'file',
        ],
        /***************************
        DEVELOPMENT
        ***************************/
        '.dev' =&gt; [
            'devMode' =&gt; true,
            'enableTemplateCaching' =&gt; false,
        ],
        $devUrl_au =&gt; [
            'siteUrl' =&gt; [ 'en_au'  =&gt; 'http://' . $devUrl_au . '/',],
        ],
        $devUrl_nz =&gt; [
            'siteUrl' =&gt; [ 'en_nz'  =&gt; 'http://' . $devUrl_nz . '/', ],
        ],
        $devUrl_us =&gt; [
            'siteUrl' =&gt; [ 'en_us'  =&gt; 'http://' . $devUrl_us . '/', ],
        ],
        /***************************
        STAGING
        ***************************/
        $testUrl_au =&gt; [
            'siteUrl' =&gt; [ 'en_au'  =&gt; 'http://' . $testUrl_au . '/', ],
        ],
        $testUrl_nz =&gt; [
            'siteUrl' =&gt; [ 'en_nz'  =&gt; 'http://' . $testUrl_nz . '/', ],
        ],
        $testUrl_us =&gt; [
            'siteUrl' =&gt; [ 'en_us'  =&gt; 'http://' . $testUrl_us . '/', ],
        ],
        /***************************
        PRODUCTION
        ***************************/
        $liveUrl_au =&gt; [
            'doAnalytics' =&gt; true,
            'siteUrl' =&gt; [ 'en_au'  =&gt; 'http://' . $liveUrl_au . '/', ],
        ],
        $liveUrl_nz =&gt; [
            'doAnalytics' =&gt; true,
            'siteUrl' =&gt; [ 'en_nz'  =&gt; 'http://' . $liveUrl_nz . '/', ],
        ],
        $liveUrl_us =&gt; [
            'doAnalytics' =&gt; true,
            'siteUrl' =&gt; [ 'en_us'  =&gt; 'http://' . $liveUrl_us . '/', ],
        ],
    ];
I found an existing solution to this. It turns out the order of the file matters and due to the "partial-match", my siteUrl was being set to the staging url and then overriden with the production url.

Proper order of multi-environment config

I'm going to use the solution outlined here
https://craftcookbook.net/recipes/foolproof-multi-environment-config