ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

In ExpressionEngine this is returned :


In PHP (no CMS) this is returned :


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


share|improve this question
up vote 6 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

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

Your Answer


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.