首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >找不到Codeigniter主页

找不到Codeigniter主页
EN

Stack Overflow用户
提问于 2018-05-27 23:25:38
回答 1查看 30关注 0票数 0

我在linux服务器上的CI项目出现了问题( windows wamp没有问题),在我的项目中,除了主页(没有任何查询字符串的地址http://example.com )之外,每条路由都工作得很好,它显示了404错误。下面是我的配置: htaccess:

代码语言:javascript
复制
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

我的routes.php:

代码语言:javascript
复制
$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:

代码语言:javascript
复制
$config['base_url'] = 'http://example.com';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; //and  "REQUEST_URI" both tested.

任何帮助都会得到重视。

EN

回答 1

Stack Overflow用户

发布于 2018-05-28 01:08:46

“它在Windows上工作,但在Linux上不能工作”的问题几乎总是由于不正确的文件命名造成的。看起来你的'default_controller‘类被命名为“索引”。文件名和类声明都必须使用大写首字符。

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

代码语言:javascript
复制
class Index extends CI_Controller

同样,请注意Index中的大写"I“。

尽管如此,CodeIgniter documentation清楚地指出,控制器不应该被命名为 Index。因此,选择另一个名称。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50553665

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档