ѡ̳
标题:
新增栏目名的伪静态 --已完成
[打印本页]
作者:
admin
时间:
2017-11-30 10:22
标题:
新增栏目名的伪静态 --已完成
RewriteEngine on
RewriteRule ^content-([0-9]+)-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
RewriteRule ^show-([0-9]+)-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=show&catid=$1&id=$2&page=$3
RewriteRule ^list-([0-9]+)-([0-9]+).html index.php?m=content&c=index&a=lists&catid=$1&page=$2
#新增栏目名伪静态
RewriteRule ^lists/([0-9A-Za-z_]+).html index.php?m=content&c=index&a=lists&catdir=$1
RewriteRule ^lists/([0-9A-Za-z_]+)/([0-9]+).html index.php?m=content&c=index&a=lists&catdir=$1&page=$2
RewriteRule ^content/([0-9A-Za-z_]+)/([0-9]+).html index.php?m=content&c=index&a=show&catdir=$1&id=$2
RewriteRule ^content/([0-9A-Za-z_]+)/([0-9]+)/([0-9]+).html index.php?m=content&c=index&a=show&catdir=$1&id=$2&page=$3
复制代码
URL规则添加
content category lists/about_us.html lists/{$catdir}.html|lists/{$catdir}/{$page}.html
content show content/about_us/1.html content/{$catdir}/{$id}.html|content/{$catdir}/{$id}/{$page}.html
复制代码
其他代码修改 phpcms/modules/content/index.php
修改show 和lists
/*$catid = $_GET['catid'] = intval($_GET['catid']);*/
/*新增自定义伪静态开始20171130*/
if(isset ($_GET['catid'])){
$catid = intval($_GET['catid']);
}else{
$catdir=$_GET['catdir'];
$s=$this->_getCategoryId($catdir);
$catid=$s[0][catid];
}
/*新增自定义伪静态结束20171130*/
复制代码
修改 phpcms/modules/content/classes/url.class.php
category_url($catid, $page = 1)
if (!$setting['ishtml']) { //如果不生成静态
/* $url = str_replace(array('{$catid}', '{$page}'), array($catid, $page), $urlrule);
if (strpos($url, '\\')!==false) {
$url = APP_PATH.str_replace('\\', '/', $url);
}*/
$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."";
if (strpos($urls, '\\')!==false) {
$urls = APP_PATH.str_replace('\\', '/', $urls);
}
$url = $domain_dir.$urls;
} else { //生成静态
复制代码
欢迎光临 ѡ̳ (http://www.sunminxuan.cn/bbs/)
Powered by Discuz! X3.4