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,'/'); }