Answers.Body: <p>Don't try to move the webroot outside the <code>web/</code> folder. The webroot is in a subdirectory for a reason, most notably security. Having the webroot in the project root means <em>everything</em> in your project is publicly accessible by default, and you definitely don't want that. It's a huge security risk.</p>
  <p>Most hosters allow you to change the webroot. See if one.com has a setting for that and if so, change it back to the <code>web/</code> directory. If it doesn't, that's a red flag for a hosting provider. I would strongly recommend ditching that provider and finding a better one that provides the basic functionality you would expect from a hosting provider.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-06T08:04:03.200Z
Answers.LastActivityDate: 2022-07-06T08:04:03.200Z
Answers.UserDisplayName: MoritzLost
Body: <p>I just transfered my website from one server to one.com. Now nothing works anymore cuz apparently one.com wants the index.php in the root directory but my index.php is in the &quot;web&quot; directory.</p>
  <p>I tried to add this to the htaccess:
  <a href="https://help.one.com/hc/en-us/articles/115005586229-How-can-I-change-the-default-start-page-" rel="nofollow noreferrer">https://help.one.com/hc/en-us/articles/115005586229-How-can-I-change-the-default-start-page-</a></p>
  <p>It loads the website but all the other links to css, js, fonts, icons are messed up. Also all the URLs have /web/ in between them.
  It looks like the webroot start path should be changed to the &quot;/web&quot; directory instead of just the root &quot;/&quot; like it was on the other server, but one.com doesn't allow that so far that I know of.</p>
  <p>Here is a snippet how my index.php files looks like in de /web directory</p>
  <pre><code>&lt;?php
  /**
   * Craft web bootstrap file
   */
  
  // Set path constants
  define('CRAFT_BASE_PATH', dirname(__DIR__));
  define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');
  
  // Load Composer's autoloader
  require_once CRAFT_VENDOR_PATH.'/autoload.php';
  
  // Load dotenv?
  if (class_exists('Dotenv\Dotenv') &amp;&amp; file_exists(CRAFT_BASE_PATH.'/.env')) {
      Dotenv\Dotenv::create(CRAFT_BASE_PATH)-&gt;load();
  }
  
  // Load and run Craft
  define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
  /** @var craft\web\Application $app */
  $app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
  $app-&gt;run();
  </code></pre>
  <hr />
  <p><strong>I also tried to change</strong>
  <code>define('CRAFT_BASE_PATH', dirname(__DIR__));</code>
  <strong>to</strong>
  <code>define('CRAFT_BASE_PATH', __DIR__);</code>
  <strong>and it removed the /web in the url but no css or js is loaded.</strong> (they are bundled from resources by webpack into the web/assets/ directory).</p>
  <p>The console gave me in this case this error:
  <a href="https://i.sstatic.net/pHMYM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pHMYM.png" alt="enter image description here" /></a></p>
  <hr />
  <p>It there another solution on the CraftCMS side to fix this problem to make everything work again like before?</p>
  <p>Thanks for in advance!</p>
  
Tags: <craft3><error><routes>
Title: Website transfer places /web in all urls, cs and js not loaded when moved up directory
ThreadText: # Website transfer places /web in all urls, cs and js not loaded when moved up directory
  
  (Asked by: username_0 on 2022-07-06)
  
  I just transfered my website from one server to one.com. Now nothing works anymore cuz apparently one.com wants the index.php in the root directory but my index.php is in the "web" directory.
  
  I tried to add this to the htaccess:
  <https://help.one.com/hc/en-us/articles/115005586229-How-can-I-change-the-default-start-page->
  
  It loads the website but all the other links to css, js, fonts, icons are messed up. Also all the URLs have /web/ in between them.
  It looks like the webroot start path should be changed to the "/web" directory instead of just the root "/" like it was on the other server, but one.com doesn't allow that so far that I know of.
  
  Here is a snippet how my index.php files looks like in de /web directory
  
  ```
  <?php
  /**
   * Craft web bootstrap file
   */
  
  // Set path constants
  define('CRAFT_BASE_PATH', dirname(__DIR__));
  define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');
  
  // Load Composer's autoloader
  require_once CRAFT_VENDOR_PATH.'/autoload.php';
  
  // Load dotenv?
  if (class_exists('Dotenv\Dotenv') && file_exists(CRAFT_BASE_PATH.'/.env')) {
      Dotenv\Dotenv::create(CRAFT_BASE_PATH)->load();
  }
  
  // Load and run Craft
  define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
  /** @var craft\web\Application $app */
  $app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
  $app->run();
  
  ```
  
  ---
  
  **I also tried to change**
  `define('CRAFT_BASE_PATH', dirname(__DIR__));`
  **to**
  `define('CRAFT_BASE_PATH', __DIR__);`
  **and it removed the /web in the url but no css or js is loaded.** (they are bundled from resources by webpack into the web/assets/ directory).
  
  The console gave me in this case this error:
  [![enter image description here](https://i.sstatic.net/pHMYM.png)](https://i.sstatic.net/pHMYM.png)
  
  ---
  
  It there another solution on the CraftCMS side to fix this problem to make everything work again like before?
  
  Thanks for in advance!
  
  **Tags:** craft3, error, routes
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-06. Score: 2
  
  Don't try to move the webroot outside the `web/` folder. The webroot is in a subdirectory for a reason, most notably security. Having the webroot in the project root means *everything* in your project is publicly accessible by default, and you definitely don't want that. It's a huge security risk.
  
  Most hosters allow you to change the webroot. See if one.com has a setting for that and if so, change it back to the `web/` directory. If it doesn't, that's a red flag for a hosting provider. I would strongly recommend ditching that provider and finding a better one that provides the basic functionality you would expect from a hosting provider.
  
  
  ---
  
  