thinkphp3.2模块名如何不区分大小写?

thinkphp3.2中已配置:‘URL_CASE_INSENSITIVE‘ => true,对于控制器及操作名大小写都可以,但仍对于模块名的大小写就运行机制出错,
比如:http://www.xxxx.com/Home 这是正常的,但换成http://www.xxxx.com/home就出错,

解决方案如下

修改 View.class.php 文件让大小写共存
替换 parseTemplate 

public function parseTemplate($template=‘‘) {        if(is_file($template)) {            return $template;        }        $depr       =   C(‘TMPL_FILE_DEPR‘);        $template   =   str_replace(‘:‘, $depr$template);        // 获取当前模块        $module   =  MODULE_NAME;        if(strpos($template,‘@‘)){ // 跨模块调用模版文件            list($module,$template)  =   explode(‘@‘,$template);        }        // 获取当前主题的模版路径        defined(‘THEME_PATH‘) or    define(‘THEME_PATH‘, $this->getThemePath($module));        // 分析模板文件规则        if(‘‘ == $template) {            // 如果模板文件名为空 按照默认规则定位            $template = CONTROLLER_NAME . $depr . ACTION_NAME;        }elseif(false === strpos($template$depr)){            $template = CONTROLLER_NAME . $depr . $template;        }        $file   =   THEME_PATH.$template.C(‘TMPL_TEMPLATE_SUFFIX‘);        if(C(‘TMPL_LOAD_DEFAULTTHEME‘) && THEME_NAME != C(‘DEFAULT_THEME‘) && !is_file($file)){            // 找不到当前主题模板的时候定位默认主题中的模板            $file   =   dirname(THEME_PATH).‘/‘.C(‘DEFAULT_THEME‘).‘/‘.$template.C(‘TMPL_TEMPLATE_SUFFIX‘);        }        //URl 大小写转换        if(!is_file($file)){            $file = $this->Get_Url($file);            if(!is_file($file)){                 $file = $this->Get_Url($file,1);             }        }        return $file;    }    private function Get_Url($f,$x=‘‘){        $a = explode(‘/‘,$f);        $b = count($a)-1;        foreach ($a as $k => $v){            if($k == $b){                if(empty($x)){                    $c .= ucfirst($v).‘/‘;                }else{                    $c .= strtolower($v).‘/‘;                }            }else{                $c .= $v.‘/‘;            }        }        return rtrim($c,‘/‘);    }

 

相关文章