storing inc.php outside doc root/security/includes
| From: | rolf vreijdenberger | Date: | Fri, 01 Nov 2002 00:04:46 +0000 |
| Subject: | storing inc.php outside doc root/security/includes | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122361@lists.php.net to get a copy of this message | ||
this is how it is done:
include ($_SERVER['DOCUMENT_ROOT'].'/../sensitivedata.inc.php');
explanation:
suppose i have a file:
www.mydomain.com/file.php
on the server it could be :
/home/sites/site168/web/file.php
this file wants to include a file with sensitive data, (or just download
some other files ) that should not be in the root (accessible via the web)
so I store this files in this directory, one higher than the doc root
/home/sites/site168/
like this
/home/sites/site168/sensitivedata.inc.php
it is now inaccesible via the web in a direct way, but not indirectly,
through other php scripts.
you include it in the way described above:
include ($_SERVER['DOCUMENT_ROOT'].'/../sensitivedata.inc.php');
$_SERVER['DOCUMENT_ROOT']
quote php manual "The document root directory under which the current script
is executing, as defined in the server's configuration file."
hope to have helped you all