Currently in my PHP coding I have to put include($_SERVER['DOCUMENT_ROOT']"./
in front of every file path in my web code. I previously asked and discovered I could set include_path. I tried setting this in both .htaccess and the .conf for the virtual host, but it just fails out and doesn't work/load the include.
Code: this is in the vhost .conf file:
<IfModule mod_php7.c>
php_value include_path ":/var/www/testdomains/domain-test1.local/php"
php_admin_flag engine on
</IfModule>
(I've tried putting this outside the IfModule area with no success.
My .php file on the webserver:
<?php require "/authcheck.php" ?>
What am I doing wrong?
<?php require "authcheck.php" ?>
. You need an include path to make files available that are not in the document-root of the webserver.require __DIR__ . '/path/to/the/file.php';
- The__DIR__
-constant contains the absolute path to the file it's written in, which will make it work even if you include this file from another file, in another location.