1

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


It there another solution on the CraftCMS side to fix this problem to make everything work again like before?

Thanks for in advance!

1 Answer 1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.