Answers.Body: <p>Aliases can be defined and/or overridden using the <a href="https://craftcms.com/docs/3.x/config/config-settings.html#aliases" rel="nofollow noreferrer"><code>aliases</code></a> config setting from your <code>config/general.php</code> file.</p>
  <p>Assuming you have your site URL set to an environment variable <code>PRIMARY_SITE_URL</code> or similar:</p>
  <pre class="lang-php prettyprint-override"><code>use craft\helpers\App;
  
  return [
      ...
      'aliases' =&gt; [
          '@web' =&gt; App::env('PRIMARY_SITE_URL'),
      ],
  ];
  </code></pre>
  <p>This is also referenced in the official docs <a href="https://craftcms.com/docs/3.x/config/#aliases" rel="nofollow noreferrer">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-21T16:29:03.760Z
Answers.Text: Great! I got it working, using your syntax. Thanks a lot! :)
Answers.UserDisplayName: qbit76
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-22T07:45:10.587Z
Answers.Text: Just for additional context as it's a little buried in the docs, the recommendation of explicitly setting the @web alias is mainly around protecting against a potential cache poisoning attack vector. By setting this alias you are ensuring only a specific site URL can be returned.
Answers.UserDisplayName: James White
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-21T16:24:10.437Z
Answers.LastActivityDate: 2022-04-21T16:24:10.437Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.Body: <h1>Update for Craft CMS V4</h1>
  <p><strong>Note</strong>: <em>You can still use the 'older' V3 syntax in V4, see the comment below.</em></p>
  <hr />
  <p>For version four, the syntax for general config has changed.<br />
  <a href="https://craftcms.com/docs/4.x/config/general.html#system" rel="nofollow noreferrer">See the docs</a></p>
  <pre class="lang-php prettyprint-override"><code>// config/general.php
  
  return GeneralConfig::create()
      ...
      // Set aliases
      -&gt;aliases([
          '@web' =&gt; App::env('PRIMARY_SITE_URL'),
      ])
  ;
  </code></pre>
  <p><em>For V3, use <a href="https://craftcms.stackexchange.com/a/39347/13762">the accepted answer</a> by Mats Mikkel Rummelhoff</em></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-10T16:57:06.730Z
Answers.Text: Technically, the old (array) syntax still works in Craft 4 and there are no plans to remove it from future Craft versions – but the new, "fluent" syntax outlined here is the one Pixel & Tonic is promoting currently :)
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-11T08:28:38.197Z
Answers.Text: @MatsMikkelRummelhoff Ah, that makes sense. I'm relatively new to Craft and noticed the syntax in the default templates that got created were different to any shown here. I'll update the answer! Thanks!
Answers.UserDisplayName: Kerwin Sneijders
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-10T14:59:14.647Z
Answers.LastActivityDate: 2023-01-12T11:43:37.017Z
Answers.LastEditDate: 2023-01-12T11:43:37.017Z
Answers.UserDisplayName: Kerwin Sneijders
Answers.Body: <p>In case of multi-environment config,
  You must paste the Mats's answer into '*' key (config/general.php), like this:</p>
  <pre><code>return [
      '*' =&gt; [
          'aliases' =&gt; [
              '@web' =&gt; App::env('PRIMARY_SITE_URL'),
          ],
          ...
      ],
  ];
  </code></pre>
  <p>I had to read the core to found how silly is this undocumented setting!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-21T10:25:54.667Z
Answers.LastActivityDate: 2022-07-21T10:25:54.667Z
Answers.UserDisplayName: Cskt Coop
Body: <p>I just stumbled upon this advice in my Craft3-system report:</p>
  <p><em>&quot;Ensure @web alias is explicitly overridden&quot;</em></p>
  <p>In which file do I need to put the override? &quot;config/general.php&quot; doesn't seem to work... </p>
  
Tags: <craft3><alias>
Title: Ensure @web alias is explicitly overridden
ThreadText: # Ensure @web alias is explicitly overridden
  
  (Asked by: username_0 on 2022-04-21)
  
  I just stumbled upon this advice in my Craft3-system report:
  
  *"Ensure @web alias is explicitly overridden"*
  
  In which file do I need to put the override? "config/general.php" doesn't seem to work...
  
  **Tags:** craft3, alias
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2022-04-21. Score: 3 | Accepted answer
  
  Aliases can be defined and/or overridden using the [`aliases`](https://craftcms.com/docs/3.x/config/config-settings.html#aliases) config setting from your `config/general.php` file.
  
  Assuming you have your site URL set to an environment variable `PRIMARY_SITE_URL` or similar:
  
  ```php
  use craft\helpers\App;
  
  return [
      ...
      'aliases' => [
          '@web' => App::env('PRIMARY_SITE_URL'),
      ],
  ];
  
  ```
  
  This is also referenced in the official docs [here](https://craftcms.com/docs/3.x/config/#aliases).
  
  > **Comments:**
  > **username_0**: Great! I got it working, using your syntax. Thanks a lot! :)  
  > **username_2**: Just for additional context as it's a little buried in the docs, the recommendation of explicitly setting the @web alias is mainly around protecting against a potential cache poisoning attack vector. By setting this alias you are ensuring only a specific site URL can be returned.  
  
  ---
  
  ### Answer by username_3 on 2023-01-10. Score: 5
  
  # Update for Craft CMS V4
  
  **Note**: *You can still use the 'older' V3 syntax in V4, see the comment below.*
  
  ---
  
  For version four, the syntax for general config has changed.  
  [See the docs](https://craftcms.com/docs/4.x/config/general.html#system)
  
  ```php
  // config/general.php
  
  return GeneralConfig::create()
      ...
      // Set aliases
      ->aliases([
          '@web' => App::env('PRIMARY_SITE_URL'),
      ])
  ;
  
  ```
  
  *For V3, use [the accepted answer](https://craftcms.stackexchange.com/a/39347/13762) by username_1*
  
  > **Comments:**
  > **username_1**: Technically, the old (array) syntax still works in Craft 4 and there are no plans to remove it from future Craft versions – but the new, "fluent" syntax outlined here is the one Pixel & Tonic is promoting currently :)  
  > **username_3**: @username_1 Ah, that makes sense. I'm relatively new to Craft and noticed the syntax in the default templates that got created were different to any shown here. I'll update the answer! Thanks!  
  
  ---
  
  ### Answer by username_4 on 2022-07-21. Score: 2
  
  In case of multi-environment config,
  You must paste the username_1's answer into '\*' key (config/general.php), like this:
  
  ```
  return [
      '*' => [
          'aliases' => [
              '@web' => App::env('PRIMARY_SITE_URL'),
          ],
          ...
      ],
  ];
  
  ```
  
  I had to read the core to found how silly is this undocumented setting!
  
  
  ---
  
  