【问题标题】:main page of Codeigniter not found找不到 Codeigniter 的主页
【发布时间】:2018-06-02 01:22:28
【问题描述】:

我的 linux 服务器中的 CI 项目有问题(在 windows wamp 中没有问题), 在我的项目中,除了显示 404 错误的主页(地址 http://example.com 没有任何查询字符串)之外,每条路线都可以正常工作。 这是我的配置: 访问:

DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 
Options -Indexes
php_flag output_buffering On

我的路由.php:

$route['default_controller'] = 'index';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['index'] = 'index/index';
$route['/'] = 'index/index'; // i have controller index.php and action index for first page that load with address example.com/index/index

我的 config.php:

$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; //and  "REQUEST_URI" both tested.

如有任何帮助,将不胜感激。

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    这个“在 Windows 上有效,在 Linux 上无效”的问题几乎都是由于文件命名不正确造成的。看来您的“default_controller”类被命名为“index”。文件名和类声明都必须使用大写的第一个字符。

    换句话说,文件必须是Index.php(注意大写I)并且声明必须是

    class Index extends CI_Controller
    

    再次注意索引中的大写“I”。

    话虽如此,CodeIgniter documentation 明确指出控制器应该被命名为 Index所以,选择其他名称

    【讨论】:

      猜你喜欢
      • 2016-08-25
      • 2020-07-14
      • 2019-12-02
      • 2015-12-19
      • 1970-01-01
      • 2017-12-20
      • 2016-11-14
      • 2015-06-29
      相关资源
      最近更新 更多