国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

PHPCMS V9自定義欄目IIS下偽靜態實現方法

2024-07-09 22:53:09
字體:
來源:轉載
供稿:網友
phpcmsV9欄目偽靜態的修改方法(支持自定義目錄名),官方程序默認偽靜態是不支持自定義欄目名的,所以今天就做了以下修改,讓其支持!
  首先看urlrewrite的規則,這個是IIS6下的,其它環境下的規則自己轉換下

RewriteRule /phpcms/(.*)(.*)/ /phpcms/index/.php/?m=contentc=indexa=listscategorydir=$1catdir=$2  
RewriteRule /phpcms/(.*)(.*)/([0-9]+)/ /phpcms/index/.php/?m=contentc=indexa=listscategorydir=$1catdir=$2page=$3 


  1、打開phpcms/modules/content目錄下的index.php找到 public function lists() {,將$catid = intval($_GET['catid']);替換成:

if(isset ($_GET['catid'])){  
                    $catid = intval($_GET['catid']);  
                }else{  
                    $catdir=$_GET['catdir'];  
                    if($catdir==""){  
                        $catdir=$_GET['categorydir'];  
                    }  
                    $s=$this->_getCategoryId($catdir);  
                    $catid=$s[0][catid];                     
                } 


  并且在最后的}?> 前添加:

/** 
         *根據欄目名獲得ID 
         * @param <type> $catdir 
         */ 
        function _getCategoryId($catdir){  
            $this->category_db = pc_base::load_model('category_model');  
            $result = $this->category_db->select(array('catdir'=>$catdir));  
           // print_r($result);  
            return $result;  
         } 


  2、打開phpcms/modules/content/classes目錄中的url.class.php,找到

  if (!$setting['ishtml']) { //如果不生成靜態

  將下面的:

$url = str_replace(array('{$catid}', '{$page}'), array($catid, $page), $urlrule);  
            if (strpos($urls, '//')!==false) { 
                    $url = APP_PATH.str_replace('//', '/', $urls);  
            } 


  替換成:

$domain_dir = '';  
            if (strpos($category['url'], '://')!==false && strpos($category['url'], '?')===false) {  
                if (preg_match('/^((http|https):////)?([^//]+)/i', $category['url'], $matches)) {  
                    $match_url = $matches[0];  
                    $url = $match_url.'/';  
                }  
                $db = pc_base::load_model('category_model');  
                $r = $db->get_one(array('url'=>$url), '`catid`');  
 
                if($r) $domain_dir = $this->get_categorydir($r['catid']).$this->categorys[$r['catid']]['catdir'].'/';  
            }  
            $categorydir = $this->get_categorydir($catid);  
            $catdir = $category['catdir'];  
            $year = date('Y',$time);  
            $month = date('m',$time);  
            $day = date('d',$time);  
            //echo $catdir;  
            $urls = str_replace(array('{$categorydir}','{$catdir}','{$year}','{$month}','{$day}','{$catid}','{$id}','{$prefix}','{$page}'),array($categorydir,$catdir,$year,$month,$day,$catid,$id,$prefix,$page),$urlrule);  
                       // echo $urls."<br>";  
                        if (strpos($urls, '//')!==false) { 
                    $urls = APP_PATH.str_replace('//', '/', $urls);  
            }  
                        $url = $domain_dir.$urls;


  3、后臺URL規則中添加:

url示例:1/  
url規則:{$categorydir}{$catdir}/|{$categorydir}{$catdir}/{$page}/ 


  更新欄目緩存就OK了。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 岳池县| 英吉沙县| 东宁县| 驻马店市| 江北区| 历史| 绥阳县| 浮梁县| 宁波市| 龙里县| 富锦市| 大城县| 灵山县| 夏河县| 金平| 汽车| 海城市| 乳源| 湖南省| 射阳县| 尚志市| 岚皋县| 蓬安县| 右玉县| 潮州市| 寻甸| 武宁县| 西华县| 甘泉县| 行唐县| 天长市| 饶平县| 泌阳县| 鄢陵县| 高州市| 莲花县| 枣阳市| 邻水| 太白县| 长阳| 塘沽区|