xxcn
发表于 2013-5-28 22:17:51
为什么大写访问的时候就报404,小写就可以正常访问,有什么特殊讲究么,是不是不应该搞大写的目录,这个搞不明白在linux下肯定会发生某些蛋疼问题啊;
xxcn
发表于 2013-5-28 22:27:16
CI2.1.3本身的一级目录也不支持大写访问文件夹;
SAE专版的一级目录支持大小写访问,但是用这个扩展类在SAE专版中没什么反应,还是一如既往的不支持多级目录;
longjianghu
发表于 2013-5-29 11:38:11
xxcn 发表于 2013-5-28 22:17 static/image/common/back.gif
为什么大写访问的时候就报404,小写就可以正常访问,有什么特殊讲究么,是不是不应该搞大写的目录,这个搞 ...
Linux系统本身就区分大小写,这个不是CI能左右的吧。
kuailewang
发表于 2013-5-29 14:02:08
本帖最后由 kuailewang 于 2013-5-29 14:04 编辑
longjianghu 发表于 2013-5-28 13:33 static/image/common/back.gif
把上面的代码保存为MY_Router.php,放到应用的core目录里。
2.1.3默认是支持一级子目录,2层的!
longjianghu
发表于 2013-5-29 16:50:49
kuailewang 发表于 2013-5-29 14:02 static/image/common/back.gif
2.1.3默认是支持一级子目录,2层的!
我说的这个是多级目录,超过2层也可以哦。
walkingsky
发表于 2013-8-28 13:14:36
支持下!呵呵
phper08
发表于 2013-9-9 19:04:12
本帖最后由 phper08 于 2013-9-9 19:08 编辑
xxcn 发表于 2013-5-28 22:17 static/image/common/back.gif
为什么大写访问的时候就报404,小写就可以正常访问,有什么特殊讲究么,是不是不应该搞大写的目录,这个搞 ...
在MY_Router类中重写set_directory(),set_class(),set_method()这几个方法,做strtolower()处理
function set_class($class)
{
$this->class = str_replace(array('/', '.'), '', $class);
}
改成
function set_class($class)
{
$this->class = str_replace(array('/', '.'), '', $class);
$this->class = strtolower($this->class);
}
xxcn
发表于 2013-9-12 20:48:51
phper08 发表于 2013-9-9 19:04 static/image/common/back.gif
在MY_Router类中重写set_directory(),set_class(),set_method()这几个方法,做strtolower()处理
改成
谢谢;
admin-D
发表于 2013-10-1 21:21:30
谢谢分享,学习了。。
冷木言
发表于 2013-11-26 15:36:45
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class MY_Router extends CI_Router
{
Function MY_Router()
{
parent::__construct();
}
function _validate_request($segments)
{
if (file_exists(APPPATH.'controllers/'.$segments.EXT))
{
return $segments;
}
if (is_dir(APPPATH.'controllers/'.$segments))
{
$this->set_directory($segments);
$segments = array_slice($segments, 1);
while(count($segments) > 0 && is_dir(APPPATH.'controllers/'.$this->directory.$segments))
{
if (substr($this->directory, -1, 1) == '/')
$this->directory = $this->directory . $segments;
else
$this->directory = $this->directory . '/' . $segments;
$segments = array_slice($segments, 1);
}
if (substr($this->directory, -1, 1) != '/')
$this->directory = $this->directory . '/';
if (count($segments) > 0)
{
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().'/'.$segments.EXT))
{
show_404($this->fetch_directory().$segments);
}
}
else
{
$this->set_class($this->default_controller);
$this->set_method('index');
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().'/' .$this->default_controller.EXT))
{
$this->directory = '';
return array();
}
}
return $segments;
}
show_404($segments);
}
}