1

I use subdomains for staging environments. That meant in Craft 2 I had to move the public_html folder content up a level and change

$craftPath = '../craft';

To:

$craftPath = 'craft';

I'm getting myself in a bit of a mess how to do this for Craft 3. I've moved the contents of 'web' into the root folder for the subdomain.

I think I have to change these settings

define('CRAFT_BASE_PATH', dirname(__DIR__));
define('CRAFT_VENDOR_PATH', CRAFT_BASE_PATH.'/vendor');

but it's a bit over my head, so any help to what I change these to would be much appreciated.

My hosting doesn't allow configuring the webserver to point to the /web folder.

Structure:

  • index.php
  • css
  • js
  • craftcms
    • config
    • modules
    • storage
    • templates
    • vendor
2

To replicate what you did in craft 2, you would change your web/index.php to:

define('CRAFT_BASE_PATH', dirname(__DIR__,1) . '/nameofthefolderwherecraftlives');

The ,1 tells craft to go up 1 level and change /nameofthefolderwherecraftlives to well... The name of the folder where craft lives :)

So for what I show you above, your structure will be:

  • web
    • index.php
  • nameofthefolderwherecraftlives
    • config
    • modules
    • storage
    • templates
    • vendor

It's here in the docs.

Hope that helps!

| improve this answer | |
  • Thanks. Makes sense but I don't think I explained throughly. I've updated my post with the structure (no web folder - it's content sits in the root) – sarah3585 Jan 22 '19 at 18:40
1

Oh I see. Then if the root folder where your index.php lives is let's say public_html you could do:

define('CRAFT_BASE_PATH', dirname(__DIR__) . '/public_html/craftcms');

Another solution would be to use __FILE__ instead of __DIR__ and you could do:

define('CRAFT_BASE_PATH', dirname(__FILE__) . '/craftcms');

However, I don't know the implications of the second option. It works for me when I test locally and doesn't break anything but I can't be sure... Maybe the Craft guys could tell us more on this..?

Anyway I hope this gets you up and running :)

| improve this answer | |

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.