PHP - 包含上面这个路径的index.php

发布于 12-01 12:30 字数 1240 浏览 0 评论 0原文

所以,我在这里使用这段代码...

<?php

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

?>

所以我有一个像这样的文件路径:

/根/文件夹/a_sub1/b_sub1/c_sub1/d_sub1

每个 *_sub 文件夹都有一个文件 index.php ,其中包含上述代码。 文件夹目录的index.php文件中有以下代码。

<?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;

?>

root 文件夹中包含 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),对吧?对我来说很有意义,但是当我浏览 folder 目录中的任何子目录时,我收到了 500 Internal Server Error...

有人可以在这里帮助我吗?

干杯:)

So, am using this code here...

<?php

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

?>

So I have a filepath like so:

/root/folder/a_sub1/b_sub1/c_sub1/d_sub1

Each *_sub folder has a file index.php with the above code in it. The folder directory has the following code in its index.php file.

<?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;

?>

The root folder has Settings.php within it that defines the $boardurl to be: http://dptest.dream-portal.net, so why is it NOT redirecting to the $boardurl when I type in the url like this?

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

To my understanding, it should include each index.php file within each path above it, until it gets to folder and than it should call upon Settings.php within the root and this should than just load up the $boardurl (http://dptest.dream-portal.net) instead right? Makes sense to me, but instead I am getting a 500 Internal Server Error when browsing any subdirectories within the folder directory...

Can someone please help me here.

Cheers :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文