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,\'/\'); }
继续阅读与本文标签相同的文章
下一篇 :
这帮吃货程序猿,给阿里食堂来了一波骚操作
-
SQL 中 Left Join 转为 Inner Join 的实际应用
2026-05-19栏目: 教程
-
82天突破1000star,项目团队梳理出软件开源必须注意的8个方面
2026-05-19栏目: 教程
-
是真“开发者”,就来一“测”到底!
2026-05-19栏目: 教程
-
山西晋城携手阿里构建城市云平台,66个政务系统已上云
2026-05-19栏目: 教程
-
阿里云物联网平台设备升级OTA演示
2026-05-19栏目: 教程
