How to include file outside document root?

前端 未结 7 507
臣服心动
臣服心动 2020-12-03 01:48

What I want do to is to include \'file1.php\' from \'domain1\' into \'file2.php\' on \'domain2\'. So what I figured I should do is something like this:

file2         


        
7条回答
  •  天涯浪人
    2020-12-03 02:13

    what you are using is bad practice. put the dependent code into domain specific. Duplicating the same code is the right approach as it does not affect the operation of both sites.

    Try creating the symlink of file1.php and included that as if it is from the local directory.

    also make sure that .htaccess has the followsymlink option set to true

    how about trying this in your file2.php in domain2?

    require_once '../../../domain1/httpdocs/file1.php';

提交回复
热议问题