Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-包含此路径上方的index.PHP_Php_Filesystems_Include - Fatal编程技术网

PHP-包含此路径上方的index.PHP

PHP-包含此路径上方的index.PHP,php,filesystems,include,Php,Filesystems,Include,所以,我在这里使用这个代码 <?php if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) include(dirname(dirname(__FILE__)) . '/index.php'); else exit; ?> 根文件夹中有Settings.php,它将$boardurl定义为:http://dptest.dream-portal.net,那么当我像这样键入url时,为什么它不重定向

所以,我在这里使用这个代码

<?php

if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
    include(dirname(dirname(__FILE__)) . '/index.php');
else
    exit;

?>
根文件夹中有Settings.php,它将
$boardurl
定义为:
http://dptest.dream-portal.net
,那么当我像这样键入url时,为什么它不重定向到
$boardurl

http://dptest.dream-portal.net/folder/a_sub1

据我所知,它应该在上面的每个路径中包含每个index.php文件,直到它到达文件夹,然后在根目录中调用Settings.php,而不仅仅是加载
$boardurl
(http://dptest.dream-portal.net)相反,对吗?这对我来说是有意义的,但是当浏览文件夹中的任何子目录时,我会收到500个内部服务器错误

有人能帮我吗


干杯:)

检查您的代码是否有超出上述内容的错误。我用我的系统试过了,它成功了首先,我将直接转到
settings.php
,查看变量以及页面加载的内容。。。然后转到下一个index.php,首先在屏幕上打印一些内容,然后尝试使用settings.php重定向。。。等等。好的,我看到一些子目录可以工作,而其他子目录不能。这对我来说没有任何意义,例如:
http://www.mydomain.com/folder/a_sub1
有效,
http://www.mydomain.com/folder/a_sub1/b_sub1
不起作用,给我一个500内部服务器错误,
http://www.mydomain.com/folder/a_sub1/b_sub1/c_sub1
工作并重定向到。我不明白?一个子目录怎么可能不工作,但非工作目录中的子目录如何工作??对我来说没有任何意义!当出现错误500时,请检查错误日志,并在include和require指令中添加_一次,以防止同一文件的多个包含(以防万一),无需担心,它会突然起作用。添加_once后缀会破坏所有路径,导致500个错误。请检查代码中是否存在超出上述范围的错误。我用我的系统试过了,它成功了首先,我将直接转到
settings.php
,查看变量以及页面加载的内容。。。然后转到下一个index.php,首先在屏幕上打印一些内容,然后尝试使用settings.php重定向。。。等等。好的,我看到一些子目录可以工作,而其他子目录不能。这对我来说没有任何意义,例如:
http://www.mydomain.com/folder/a_sub1
有效,
http://www.mydomain.com/folder/a_sub1/b_sub1
不起作用,给我一个500内部服务器错误,
http://www.mydomain.com/folder/a_sub1/b_sub1/c_sub1
工作并重定向到。我不明白?一个子目录怎么可能不工作,但非工作目录中的子目录如何工作??对我来说没有任何意义!当出现错误500时,请检查错误日志,并在include和require指令中添加_一次,以防止同一文件的多个包含(以防万一),无需担心,它会突然起作用。添加_once后缀会破坏所有路径,导致500错误。
<?php

// Look for Settings.php....
if (file_exists(dirname(dirname(__FILE__)) . '/Settings.php'))
{
    // Found it!
    require(dirname(dirname(__FILE__)) . '/Settings.php');
    header('Location: ' . $boardurl);
}
// Can't find it... just forget it.
else
    exit;

?>