phpcms v9 目录式伪静态
来源:互联网 发布:知乎匿名回答在哪看 编辑:程序博客网 时间:2024/05/20 05:09
phpcms v9 目录式伪静态
官方程序默认伪静态是不支持自定义栏目名的
如何才能实现目录式伪静态?
pc 能够通过目录访问到正确页面
默认可访问链接==>
index.php?m=content&c=index&a=lists&catid=1
index.php?m=content&c=index&a=show&catid=1&id=18
需要可访问链接 ==>
index.php?m=content&c=index&a=lists&catdir=dir1
index.php?m=content&c=index&a=show&catdir=dir1&id=18
pc后台
URL规则管理
需要正确配置ps: pc默认情况下 URL规则中
{$categorydir}
{$catdir}
无效,也需要解决.htaccess
文件配置好对应伪静态
栏目伪静态时 URL规则中 {$categorydir}
{$catdir}
无效解决方法
栏目页伪静态(不生成HTML)时,URL规则中
{$categorydir}
{$catdir}
仍显示为{$categorydir}
{$catdir}
解决方法。
打开
phpcms\modules\content\classes\url.class.php
定位到122
行$url = str_replace(array('{$catid}', '{$page}'), array($catid, $page), $urlrule);
替换成
$category_dir = $this->get_categorydir($catid);$url = str_replace(array('{$catid}', '{$page}','{$catdir}','{$categorydir}'), array($catid, $page,$category['catdir'],$category_dir), $urlrule);
PS: 只做到这一步,生成的URL还是会有BUG的(分页url里有重复的栏目路径),继续往下,全部写完就没问题了!
让pc能通过目录式链接访问网站
phpcms v9 默认是无法通过栏目名访问到正确页面的,因为缺少必要的参数。
让 list页面
支持目录式访问网站
打开phpcms\modules\content\index.php 定位到
207
行$catid = $_GET['catid'] = intval($_GET['catid']);
替换成
if(isset ($_GET['catid'])){ $catid = $_GET['catid'] = intval($_GET['catid']);} else{ $catid=$this->_getCategoryId($_GET['catdir']);}
在该文件底部(
}?>
前)增加一个方法private function _getCategoryId($catdir){ if(!strpos($catdir,'/')) { $dirname = $catdir; } else{ $dirname = end(explode('/',$catdir)); } $this->category_db = pc_base::load_model('category_model'); $result = $this->category_db->get_one(array('catdir'=>$dirname)); return $result['catid'];}
让 show页面
支持目录式访问网站
打开phpcms\modules\content\index.php 定位到
35-36
行$catid = intval($_GET['catid']);$id = intval($_GET['id']);
替换成
if(isset ($_GET['catid'])){ $catid = intval($_GET['catid']);} else{ $catid=$this->_getCategoryId($_GET['catdir']);}if(isset($_GET['id'])){ $id = intval($_GET['id']);} else{ $id = $this->_getPrefixId($_GET['catdir'],$_GET['prefix']);}
在该文件底部(
}?>
前)增加一个方法private function _getPrefixId($catdir,$prefix){ if(!strpos($catdir,'/')) { $dirname = $catdir; } else{ $dirname = end(explode('/',$catdir)); } $this->category_db = pc_base::load_model('category_model'); $result = $this->category_db->get_one(array('catdir'=>$dirname)); $catid = $result['catid']; $siteids = getcache('category_content','commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_'.$siteid,'commons'); if(!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type']!=0) showmessage(L('information_does_not_exist'),'blank'); $this->category = $CAT = $CATEGORYS[$catid]; $this->category_setting = $CAT['setting'] = string2array($this->category['setting']); $siteid = $GLOBALS['siteid'] = $CAT['siteid']; $MODEL = getcache('model','commons'); $modelid = $CAT['modelid']; $tablename = $this->db->table_name = $this->db->db_tablepre.$MODEL[$modelid]['tablename']; $result = $this->db->get_one(array('prefix'=>$prefix)); if(empty($result)){ $result = $this->db->get_one(array('id'=>$prefix)); } return $result['id'];}
URL规则管理 与 伪静态规则
伪静态规则
需要根据URL规则
进行自定义
自带伪静态规则
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
第1组 URL规则
or 伪静态规则
category
的URL示例
orURL规则
dir/index.html|dir/list-1.html{$catdir}/index.html|{$catdir}/list-{$page}.html
show
的URL示例
orURL规则
dir/1.html|dir/1-1.html{$catdir}/{$id}.html|{$catdir}/{$id}-{$page}.html
伪静态规则
RewriteEngine onRewriteRule ^index.html index.phpRewriteCond $1 !^(api|caches|html|kc-path|phpcms|phpsso_server|statics|uploadfile)RewriteRule ^(\w+)/(list\-(\d+)\.html)? index.php?m=content&c=index&a=lists&catdir=$1&page=$3RewriteRule ^(\w+)/(\d+)(\-(\d+))?\.html index.php?m=content&c=index&a=show&catdir=$1&id=$2&page=$4
第2组 URL规则
or 伪静态规则
category
的URL示例
orURL规则
dir.html|dir-1.html{$catdir}.html|{$catdir}-{$page}.html
show
的URL示例
orURL规则
dir/1.html|dir/1-1.html{$catdir}/{$id}.html|{$catdir}/{$id}-{$page}.html
伪静态规则
RewriteEngine onRewriteRule ^index.html index.phpErrorDocument 404 /Error.htmlRewriteCond $1 !^(api|caches|html|kc-path|phpcms|phpsso_server|statics|uploadfile)RewriteRule ^(\w+)/(\d+)(\-(\d+))?\.html index.php?m=content&c=index&a=show&catdir=$1&id=$2&page=$4RewriteCond $1 !^(Error|js|index)RewriteRule ^((\w+)(\-(\d+))?)\.html index.php?m=content&c=index&a=lists&catdir=$2&page=$4
- phpcms v9 目录式伪静态
- PHPCMS V9 如何启用伪静态
- phpcms v9 栏目伪静态完全自定义为栏目英文目录名
- phpcms V9伪静态设置(win2003 iis6.0)
- PHPcms V9 的目录结构
- 配置PHPCMS伪静态
- phpcms修改伪静态
- phpcms URL伪静态
- PHPCMS v9 在windows2008系统 IIS7 下设置伪静态的方法
- phpcms 筛选伪静态设置
- phpcms伪静态设置方法
- phpcms V9全站伪静态设置方法
- PHPCMS V9系统配置文件和模板目录
- PHPCMS V9系统文件目录结构
- phpcms v9 默认模板文件目录结构
- phpcms V9 默认模板文件目录
- phpcms v9框架的目录结构分析
- phpcms V9 常用文件目录结构
- MySql 时间类型转为字符串
- java按位运算符(&、|、~、^) 移位操作符(>> << >>> )
- Flum入门必备知识
- 变量的存储类别小总结
- 20.当数据量超过一万后天接收不到前台传递过来的数据
- phpcms v9 目录式伪静态
- Android 如何使用小的Ratingbar
- Linux基础
- 使用Python3计算HTTP的摘要Response值
- 随机函数的应用
- 单调队列学习笔记
- HDU 3763 C D(二分)
- Java学习——面向对象基础
- java设计模式-单例模式