升级到3.0出现了404错误
CI更新到3.0的时候配置域名指向该项目出现404错误,指向之前的项目(版本2.2)没有该问题。路由配置如下$route['default_controller'] = 'Index';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
我也出现这种情况,URL有设置参数是正常 如:indxe.php?c=Welcome;要是未设置参数 如直接访问index.php默认的控制器没有生效,显示:
Unable to determine what should be displayed. A default route has not been specified in the routing file
最后查看代代码发现在system\core\Router.php中未给$this->default_controller赋值,获取不到默认的控制器。
解决办法:
在Function _set_routing()内将下面的代码提前放到这个函数内的前面:
// Load the routes.php file.
if (file_exists(APPPATH.'config/routes.php'))
{
include(APPPATH.'config/routes.php');
}
if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}
// Validate & get reserved routes
if (isset($route) && is_array($route))
{
isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
unset($route['default_controller'], $route['translate_uri_dashes']);
$this->routes = $route;
} 本帖最后由 Closer 于 2015-4-22 18:00 编辑
LUISHOU 发表于 2015-4-22 17:55
问题:是不是路由配置和控制器的名称和class的名称大小写要一致?还是都是大写?
...
路由和 Class 沒有強制
但手冊上建議 Class 首字大寫
而檔名則是強制首字大寫
static/image/hrline/line3.png
Windows 下無感
Linux 下錯誤會一堆 (因為大小寫敏感)
因為這點,3.0 才做了強制大寫的要求
我是習慣 Class 和檔名首字大寫了
(P.S: 包括 View 端的檔名)
一叶扁舟 发表于 2015-4-23 09:32
那看起來我沒會錯意
他的其他是指該字串
例如 :
正確 - Testline
錯誤 - testline
錯誤 - TestLine
參考 CI 手冊 - 模型
裡面有提到 : Model_name 是模型类的名字。 类名的首字母必须大写,其他字母小写。 并且确保你的类继承了基本模型类(Base Model Class)。
请问一下可能的原因有哪些? 你的控制器檔名與 Class 名
英文字是否首字大寫? Closer 发表于 2015-4-22 17:45
你的控制器檔名與 Class 名
英文字是否首字大寫?
问题:是不是路由配置和控制器的名称和class的名称大小写要一致?还是都是大写?
Changed filenaming convention (class file names now must be Ucfirst and everything else in lowercase). 一叶扁舟 发表于 2015-4-23 09:12
Changed filenaming convention (class file names now must be Ucfirst and everything else in lowercase ...
這是指 Class 名和 File 名開頭英文字都以小寫來表達? 其实我英文也一般般,在等官方的中文文档……
这里意思大概就是 改变了文件命名规则,类文件名必须首字母大写其他的小写
这里’其他‘不知道是其他文件类型还是类文件名首字母外其他字母…… Closer 发表于 2015-4-23 09:19
這是指 Class 名和 File 名開頭英文字都以小寫來表達?
其实我英文也一般般,在等官方的中文文档……
这里意思大概就是 改变了文件命名规则,类文件名必须首字母大写其他的小写
这里’其他‘不知道是其他文件类型还是类文件名首字母外其他字母……
页:
[1]
2