Answers.Body: <p>Have you changed your server configuration at all recently?</p>
  <p>By &quot;change&quot; I mean add another domain or subdomain, go from staging to production, switch hosts, etc.</p>
  <p>It sounds like maybe Craft thinks the document root (what Craft calls the <code>@webroot</code>) is one spot, but the web server is setup for something else.</p>
  <p>Shared hosting providers that use cpanel for example are notorious for this. Usually the &quot;default&quot; virtual host will expect you to put all your files in a certain directory, usually <code>public_html</code> or <code>www</code>. This is known as the web server root and that's typically where a static &quot;homepage&quot; is served out of it. In Craft's case, it's <code>index.php</code>.</p>
  <p>However, Craft expects the rest of application files to live one folder/directory above that web root. Shared hosting often doesn't let you move files above the webroot so you'd need to <a href="https://craftcms.com/knowledge-base/moving-craft-files" rel="nofollow noreferrer">move files around</a>.</p>
  <p>I usually test things like this by ignoring Craft for a moment:</p>
  <ol>
  <li>Create a new file, <code>testindex.php</code> and add <code>&lt;?php phpinfo();</code> to it.</li>
  <li>Throw it in the same folder as Craft's <code>index.php</code></li>
  <li>Visit the file in your web browser.  It should be <code>whatever.com/testindex.php</code> if everything's pointed properly.</li>
  </ol>
  <p>(If Craft is in a sub folder it'll be at <code>/subfolder/</code> instead.)</p>
  <p>Two things could happen:</p>
  <ul>
  <li>If you get a <strong>404 not found error</strong> that means the webroot / document root is not where you think it is. Try <code>example.com/public/testindex.php</code> or <code>/web/testindex.php</code></li>
  <li>If it <strong>does</strong> work, PHP will spit out a bunch of configuration information that's handy including showing what your PHP environment sees.</li>
  </ul>
  <p>Search for <code>DOCUMENT_ROOT</code> and it'll show where the &quot;base&quot; of your website is supposed to live. In a default install of Craft, all of the files from the <code>web</code> folder go here.</p>
  <p>Make sure to remove the testing file after you're done.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-06T00:21:15.247Z
Answers.LastActivityDate: 2021-12-06T00:21:15.247Z
Answers.UserDisplayName: RitterKnight
Answers.Body: <p>You should specify the <code>@webroot</code> alias in your <code>config/general.php</code>. To make sure the path is always absolute and always correct for each environment, you can use the <a href="https://craftcms.com/docs/4.x/config/#craft-base-path" rel="nofollow noreferrer"><code>CRAFT_BASE_PATH</code> constant</a>.</p>
  <pre class="lang-php prettyprint-override"><code>// config/general.php
  return [
      '*' =&gt; [
          'aliases' =&gt; [
              '@webroot' =&gt; CRAFT_BASE_PATH . '/web',
          ],
      ],
  ];
  </code></pre>
  <p>You can find a similar example in the <a href="https://craftcms.com/docs/3.x/config/#aliases" rel="nofollow noreferrer">Craft documentation on aliases</a>.</p>
  <p>To find out if the alias is defined correctly, put this somewhere in a template and check the output:</p>
  <pre class="lang-twig prettyprint-override"><code>{% dd craft.app.config.general.aliases %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T12:58:35.677Z
Answers.Text: I believe I had this, it was what was where '/web' was that created an error - e.g. '/www/public_html/public' was then causing a plugin to create a string of folders called /www/public_html/public inside the public folder.
  
  If my absolute path is /storage/[username]/www/public_html/public where the index.php file sits, was that correct?
Answers.UserDisplayName: Emma Swann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T13:09:21.463Z
Answers.Text: @EmmaSwann Looks correct to me … maybe post your `config/general.php` to see if there's an inconsistency somewhere. Also, it might just be a buggy plugin. What plugin is causing this? To check if the path is set correctly, put this somewhere in a template and check the output: `{% dd craft.app.config.general.aliases %}`
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T13:24:28.073Z
Answers.Text: Thanks - that tag shows what should be there - currently siteUrl is defined to the domain name.
  
  The plugin that I know causes an issue is Blitz Cache - I can see the path to where the cache sits changing in error as soon as the @webroot is defined.
Answers.UserDisplayName: Emma Swann
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T15:00:14.557Z
Answers.Text: @EmmaSwann Which command is producing this error? What path are you seeing in the error if you define the webroot as mentioned above?  Also, what is your [cache storage setting](https://putyourlightson.com/plugins/blitz#cache-storage) for Blitz?
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T12:53:55.383Z
Answers.LastActivityDate: 2023-01-08T15:44:52.517Z
Answers.LastEditDate: 2023-01-08T15:44:52.517Z
Answers.UserDisplayName: MoritzLost
Body: <p>Getting &quot;Error clearing cache Control panel resources: Unable to clear control panel resources because the location isn't known for console commands&quot; and the recommendation to set @webroot in config/general.php.</p>
  <p>However, when I had previously done that, at least one plugin created a new /www/public_html/ <strong>below</strong> the folder in which Craft sits, and the assets from it weren't accessible in templates.</p>
  <p>Is there an easy way to specify the absolute path somehow?</p>
  
Tags: <config><console>
Title: @webroot - how to find out path?
ThreadText: # @webroot - how to find out path?
  
  (Asked by: username_0 on 2021-12-03)
  
  Getting "Error clearing cache Control panel resources: Unable to clear control panel resources because the location isn't known for console commands" and the recommendation to set @webroot in config/general.php.
  
  However, when I had previously done that, at least one plugin created a new /www/public\_html/ **below** the folder in which Craft sits, and the assets from it weren't accessible in templates.
  
  Is there an easy way to specify the absolute path somehow?
  
  **Tags:** config, console
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2021-12-06. Score: 1
  
  Have you changed your server configuration at all recently?
  
  By "change" I mean add another domain or subdomain, go from staging to production, switch hosts, etc.
  
  It sounds like maybe Craft thinks the document root (what Craft calls the `@webroot`) is one spot, but the web server is setup for something else.
  
  Shared hosting providers that use cpanel for example are notorious for this. Usually the "default" virtual host will expect you to put all your files in a certain directory, usually `public_html` or `www`. This is known as the web server root and that's typically where a static "homepage" is served out of it. In Craft's case, it's `index.php`.
  
  However, Craft expects the rest of application files to live one folder/directory above that web root. Shared hosting often doesn't let you move files above the webroot so you'd need to [move files around](https://craftcms.com/knowledge-base/moving-craft-files).
  
  I usually test things like this by ignoring Craft for a moment:
  
  1. Create a new file, `testindex.php` and add `<?php phpinfo();` to it.
  2. Throw it in the same folder as Craft's `index.php`
  3. Visit the file in your web browser. It should be `whatever.com/testindex.php` if everything's pointed properly.
  
  (If Craft is in a sub folder it'll be at `/subfolder/` instead.)
  
  Two things could happen:
  
  * If you get a **404 not found error** that means the webroot / document root is not where you think it is. Try `example.com/public/testindex.php` or `/web/testindex.php`
  * If it **does** work, PHP will spit out a bunch of configuration information that's handy including showing what your PHP environment sees.
  
  Search for `DOCUMENT_ROOT` and it'll show where the "base" of your website is supposed to live. In a default install of Craft, all of the files from the `web` folder go here.
  
  Make sure to remove the testing file after you're done.
  
  
  ---
  
  ### Answer by username_2 on 2021-12-03. Score: 1
  
  You should specify the `@webroot` alias in your `config/general.php`. To make sure the path is always absolute and always correct for each environment, you can use the [`CRAFT_BASE_PATH` constant](https://craftcms.com/docs/4.x/config/#craft-base-path).
  
  ```php
  // config/general.php
  return [
      '*' => [
          'aliases' => [
              '@webroot' => CRAFT_BASE_PATH . '/web',
          ],
      ],
  ];
  
  ```
  
  You can find a similar example in the [Craft documentation on aliases](https://craftcms.com/docs/3.x/config/#aliases).
  
  To find out if the alias is defined correctly, put this somewhere in a template and check the output:
  
  ```twig
  {% dd craft.app.config.general.aliases %}
  
  ```
  
  > **Comments:**
  > **username_0**: I believe I had this, it was what was where '/web' was that created an error - e.g. '/www/public_html/public' was then causing a plugin to create a string of folders called /www/public_html/public inside the public folder.  If my absolute path is /storage/[username]/www/public_html/public where the index.php file sits, was that correct?  
  > **username_2**: @username_0 Looks correct to me … maybe post your `config/general.php` to see if there's an inconsistency somewhere. Also, it might just be a buggy plugin. What plugin is causing this? To check if the path is set correctly, put this somewhere in a template and check the output: `{% dd craft.app.config.general.aliases %}`  
  > **username_0**: Thanks - that tag shows what should be there - currently siteUrl is defined to the domain name.  The plugin that I know causes an issue is Blitz Cache - I can see the path to where the cache sits changing in error as soon as the @webroot is defined.  
  > **username_2**: @username_0 Which command is producing this error? What path are you seeing in the error if you define the webroot as mentioned above?  Also, what is your [cache storage setting](https://putyourlightson.com/plugins/blitz#cache-storage) for Blitz?  
  
  ---
  
  