【问题标题】:Server Check Codeigniter服务器检查 Codeigniter
【发布时间】:2014-05-23 07:38:55
【问题描述】:

我的重定向和服务器检查不适用于我在 codeigniter 中的 index.php。

我有一个用于 codeigniter 的前端安装向导,有 4 个步骤,第 4 步是最后一步。我正在努力做到这一点,如果用户已完成这些步骤并已达到第 4 步,则可以访问该域/服务器上的网站。

目前我使用的代码一直重定向到我的安装 URL 的 index.php,即使我已经完成了所有步骤。

下面这段代码在我的主要 index.php 上

if (!file_exists('install/index.php')) {

// Make sure we've not already tried this
if (strpos($_SERVER['REQUEST_URI'], '/install/')) {
header('Status: 404');
exit;
}

// Otherwise go to installer
header('Location: '.rtrim($_SERVER['REQUEST_URI'], '/').'/install/');
exit;
}

欢迎控制器

public function index()
    {

        if (!file_exists('install/index.php')) {

        // Make sure we've not already tried this
        if (strpos($_SERVER['REQUEST_URI'], '/install/')) {
        header('Status: 404');
        exit;
        }

        // Otherwise go to installer
        header('Location: '.rtrim($_SERVER['REQUEST_URI'], '/').'/install/');
        exit;
        } else {

        $this->load->view('welcome_message');
    }
}

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    您可以将此代码放在welcome controller

    将代码放在控制器的索引函数中

    欢迎类扩展 CI_Controller { 公共函数索引() { /* 你的重定向代码*/ } 公共函数 cmets() { echo '看看这个!'; } }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 2012-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多