Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

I'm currently using the $_SERVER['DOCUMENT_ROOT'] variable inside my config file.

In ExpressionEngine this is returned :

/Applications/MAMP/htdocs/devee

In PHP (no CMS) this is returned :

/Applications/MAMP/htdocs

Is there a place, where ExpressionEngine is changing the $_SERVER['DOCUMENT_ROOT'] ?

Thanks.

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

I would avoid using DOCUMENT_ROOT altogether, to avoid issues between servers. The doc root is specified in your apache config, and depending on your apache setup, isn't always guaranteed to give you the correct path to your root folder.

It's much more reliable to use dirname(__FILE__) (or __DIR__ in PHP 5.3+) for the directory of the current script, and go from there. E.g. (in your config.php file):

$root = realpath(dirname(__FILE__).'/../../../');
$config['theme_folder_path'] = $root.'themes/';
share|improve this answer
    
Much more flexible than document_root. Thanks you ! –  Simon Dec 31 '12 at 10:27
add comment

I would assume ExpressionEngine is giving you the path to your system folder, since that is were the config.php file is located.

The $_SERVER['DOCUMENT_ROOT'] provides:

The document root directory under which the current script is executing, as defined in the server's configuration file.

It doesn't provide the base path to your html folder; it provides the path to the executing file/script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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