<p>The keys in the array returned from the multi-env config are matched to the value for the <code>CRAFT_ENVIRONMENT</code> <a href="https://craftcms.com/docs/5.x/configure.html#env" rel="nofollow noreferrer">environment variable</a> (excluding the asterisk <code>*</code>, which contains configuration that should apply in <em>all</em> environments).</p>
<p>That means that for the configuration below the <code>'production'</code> key in your multi-env config file to apply in your production environment, the production environment needs a <code>CRAFT_ENVIRONMENT=production</code> environment variable (typically set in a <code>.env</code> file at the root of your Craft install).</p>

CC BY-SA 4.0
2024-11-13T20:09:01.157Z
2024-11-13T20:09:01.157Z
Mats Mikkel Rummelhoff
<p>I am trying to implement [Multi-Environment Configs][1] on my Craft CMS 5. i've change my general.php to this. But i always got error <code>{&quot;name&quot;:&quot;Not Found&quot;,&quot;message&quot;:&quot;Page not found.&quot;,&quot;code&quot;:0,&quot;status&quot;:404,&quot;type&quot;:&quot;yii\\web\\NotFoundHttpException&quot;}</code>. does anyone have a solution for this?</p>
<pre><code>return [
    '*' =&gt; [
        // Applies to all environments:
        'defaultWeekStartDay' =&gt; 1,
        'omitScriptNameInUrls' =&gt; true,
        'allowAdminChanges' =&gt; false,
    ],

    'dev' =&gt; [
        // Only applies to development environments, overriding anything in `*`:
        'allowAdminChanges' =&gt; true,
        'devMode' =&gt; true,
    ],

    'production' =&gt; [
        // Only applies to the production environment, overriding anything in `*`:
        'cpTrigger' =&gt; 'secret-word',
    ],
];


  [1]: https://craftcms.com/docs/5.x/configure.html#multi-environment-configs
</code></pre>

CC BY-SA 4.0
2024-11-12T10:08:48.730Z
Which page are you trying to open? If it’s the Control Panel, and you've followed the configuration in the documentation, then your Control Panel URL should be `localhost:{port}/secret-word` and your front-end URL should be: `localhost:{port}`. Unless you have additional configurations beyond those in the documentation, I'm not entirely sure what's causing the "Not Found" error.
Nixxian365
CC BY-SA 4.0
2024-11-12T10:11:04.693Z
*update*: the CP Url in Dev environment should be: `localhost:{port}/admin` and Production should be `localhost:{port}/secret-word`
Nixxian365
<multi-environment><craft5>
Multi-Environment Configs Failed on Craft cms 5
# Multi-Environment Configs Failed on Craft cms 5

(Asked by: username_0 on 2024-11-12)

I am trying to implement [Multi-Environment Configs][1] on my Craft CMS 5. i've change my general.php to this. But i always got error {"name":"Not Found","message":"Page not found.","code":0,"status":404,"type":"yii\\web\\NotFoundHttpException"}. does anyone have a solution for this?
return [
    '*' => [
        // Applies to all environments:
        'defaultWeekStartDay' => 1,
        'omitScriptNameInUrls' => true,
        'allowAdminChanges' => false,
    ],

    'dev' => [
        // Only applies to development environments, overriding anything in `*`:
        'allowAdminChanges' => true,
        'devMode' => true,
    ],

    'production' => [
        // Only applies to the production environment, overriding anything in `*`:
        'cpTrigger' => 'secret-word',
    ],
];


  [1]: https://craftcms.com/docs/5.x/configure.html#multi-environment-configs

**Tags:** multi-environment, craft5
> **Comments:**
> **username_1**: Which page are you trying to open? If it’s the Control Panel, and you've followed the configuration in the documentation, then your Control Panel URL should be `localhost:{port}/secret-word` and your front-end URL should be: `localhost:{port}`. Unless you have additional configurations beyond those in the documentation, I'm not entirely sure what's causing the "Not Found" error.  
> **username_1**: *update*: the CP Url in Dev environment should be: `localhost:{port}/admin` and Production should be `localhost:{port}/secret-word`  

---

## 1 answers

### Answer by username_2 on 2024-11-13. Score: 0

The keys in the array returned from the multi-env config are matched to the value for the `CRAFT_ENVIRONMENT` [environment variable](https://craftcms.com/docs/5.x/configure.html#env) (excluding the asterisk `*`, which contains configuration that should apply in *all* environments).

That means that for the configuration below the `'production'` key in your multi-env config file to apply in your production environment, the production environment needs a `CRAFT_ENVIRONMENT=production` environment variable (typically set in a `.env` file at the root of your Craft install).


---

