【问题标题】:404 page not found in codeigniter 3在 codeigniter 3 中找不到 404 页面
【发布时间】:2016-02-21 09:02:57
【问题描述】:

当我将 codeigniter 上传到服务器时,我遇到了 404。我尝试了所有已知的方法,但仍然无法找到解决方案 我的.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

config.php

$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';

routes.php

$route['default_controller'] = 'lloyd';

控制器 lloyd.php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class Lloyd extends CI_Controller{
    public function __construct() {
        parent::__construct();
    }

    public function index()
    {       
        $theme = $this->aauth->get_system_var("theme");
        $this->load->view($theme . '/home');
    }
 }

【问题讨论】:

  • $config['uri_protocol'] = 'REQUEST_URI';没用
  • 这可能是你的文件名,如我的回答所示,

标签: codeigniter routes http-status-code-404 codeigniter-2


【解决方案1】:

首先使用你的 uri_protocol

试试这个

$config['uri_protocol'] = 'REQUEST_URI';

代替

$config['uri_protocol'] = 'QUERY_STRING';

在 CI3 版本中,文件名的首字母必须大写,与类相同。

劳埃德.php

代替

劳埃德.php

带有基本网址的所有方法都可以很好地使用 / 最后也。

$config['base_url'] = 'http://example.com/';

确保您的项目主目录中有 htaccess 文件。

【讨论】:

  • Lloyd.php 工作,codeigniter 2 不接受此命名约定
  • 现在发生了一些变化。 codeigniter 3 和 2 的用户指南现在在这里codeigniter.com/docs
猜你喜欢
  • 1970-01-01
  • 2020-07-14
  • 2019-12-02
  • 1970-01-01
  • 2016-11-14
  • 1970-01-01
  • 1970-01-01
  • 2016-12-11
相关资源
最近更新 更多