On my local dev sever, as well as the production server, the craft folder is one level above web root, so $craftPath in index.php is set like so:

$craftPath = '../craft';

On the staging server, the craft folder is two levels above web root, so $craftPath needs to be:

$craftPath = '../../craft';

Can this be accomplished in a single index.php file? Something similar to the multi-environment array in config/general.php and config/db.php perhaps?

1 Answer 1


Should be able to. Use a switch statement to check on the host and then server up the correct environment configuration like so:


switch (strtolower($_SERVER['SERVER_NAME']))
    // Staging
    case 'stage.mydomain.com' :
        define('CRAFT_ENVIRONMENT', 'stage');
        $craftPath = '../../craft';

    // Local
    default :
        define('CRAFT_ENVIRONMENT', 'local');
        $craftPath = '../craft';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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