1. 1,后台增加url规则,增加后.导航上,或分页号上,会自动替换为静态的样式.类似www.abc.com/news/2/ 2表示页码
  2. phpcms v9 的后台扩展,url规则,添加两个规则,
  3. 一个是名称为category的规则,规则的前面的斜线可以去掉,不过可能影响分页问题
  4. /{$catdir}/|/{$catdir}/{$page}/
  5. url示例为 www.abc.com/news/
  6. 一个是名称为show规则
  7. {$catdir}/{$id}.html|{$catdir}/{$id}_{$page}.html
  8. 示例为www.abc.com/news/99.html
  9. 然后,找到想伪静态的栏目,修改.生成html设置,生成Html全设置为否,url规则选择自己刚才设置的.保存,
  10. 最后更新栏目缓存及批量更新url,不更新无效
  11. 2,如果为apache的服务器空间,伪静态规则如下,注意,要保存在.htaccess 文件中,并上传到网站根目录中,其它规则自己转换
  12. RewriteEngine on
  13. #静态文件以及API目录不需要伪静态
  14. RewriteRule ^(statics|api|uploadfile)(.*) - [L]
  15. #栏目页
  16. RewriteRule ^([0-9A-Za-z_]*)$ index.php?m=content&c=index&a=lists&catdir=$1
  17. RewriteRule ^([0-9A-Za-z_]*)/$ index.php?m=content&c=index&a=lists&catdir=$1
  18. RewriteRule ^([0-9A-Za-z_]*)/([0-9]+)$ index.php?m=content&c=index&a=lists&catdir=$1&page=$2
  19. RewriteRule ^([0-9A-Za-z_]*)/([0-9]+)/$ index.php?m=content&c=index&a=lists&catdir=$1&page=$2
  20. #上面栏目分页,是完全的字母加数字的形式,如www.abc.com/news/2 ,后面不带其它字符,或加一个/字符,如果服务器伪静态匹配到了"域名/字母/数字/"的组合,则会自动跳转到index.php?m=content&c=index&a=lists&catdir=$1&page=$2这个页面中.所以.前面的规则不可重复,否则会错乱.
  21. #内容页
  22. RewriteRule ^([0-9A-Za-z_]*)/([0-9]+)\.html$ index.php?m=content&c=index&a=show&catdir=$1&id=$2
  23. 3,文件,phpcms\phpcms\modules\content\index.php中
  24. 搜索
  25. $catid = intval($_GET['catid']);
  26. 一共两处,修改为
  27. if(isset ($_GET['catid'])){
  28. $catid = intval($_GET['catid']);
  29. }else{
  30. $catdir=$_GET['catdir'];
  31. $s=$this->_getCategoryId($catdir);
  32. $catid=$s[0][catid];
  33. }
  34. 然后,在最下面
  35. } 这个 大括号的前面增加一个函数,如下
  36. protected  function _getCategoryId($catdir){
  37. $this->category_db = pc_base::load_model('category_model');
  38. $result = $this->category_db->select(array('catdir'=>$catdir));
  39. // print_r($result);
  40. return $result;
  41. }
  42. 4, 打开phpcms\modules\content\classes\url.class.php,找到
  43.   if (!$setting['ishtml']) { //如果不生成静态
  44.   将下面的:
  45. $url = str_replace(array('{$catid}', '{$page}'), array($catid, $page), $urlrule);
  46. if (strpos($urls, '\\')!==false) {
  47. $url = APP_PATH.str_replace('\\', '/', $urls);
  48. }
  49. 整体替换为
  50. $domain_dir = '';
  51. if (strpos($category['url'], '://')!==false && strpos($category['url'], '?')===false) {
  52. if (preg_match('/^((http|https):\/\/)?([^\/]+)/i', $category['url'], $matches)) {
  53. $match_url = $matches[0];
  54. $url = $match_url.'/';
  55. }
  56. $db = pc_base::load_model('category_model');
  57. $r = $db->get_one(array('url'=>$url), '`catid`');
  58. if($r) $domain_dir = $this->get_categorydir($r['catid']).$this->categorys[$r['catid']]['catdir'].'/';
  59. }
  60. $categorydir = $this->get_categorydir($catid);
  61. $catdir = $category['catdir'];
  62. $year = date('Y',$time);
  63. $month = date('m',$time);
  64. $day = date('d',$time);
  65. //echo $catdir;
  66. $urls = str_replace(array('{$categorydir}','{$catdir}','{$year}','{$month}','{$day}','{$catid}','{$id}','{$prefix}','{$page}'),array($categorydir,$catdir,$year,$month,$day,$catid,$id,$prefix,$page),$urlrule);
  67. // echo $urls."<br>";
  68. if (strpos($urls, '\\')!==false) {
  69. $urls = APP_PATH.str_replace('\\', '/', $urls);
  70. }
  71. $url = $domain_dir.$urls;

phpcms v9 栏目伪静态完全自定义为栏目英文目录名的更多相关文章

  1. Phpcms V9全站伪静态设置方法

    为什么要伪静态?具体在这里就不说了,你懂的!一方面更新修改后不需要生成静态文件,另一方面为了SEO! 访问规则如下 1 2 list-{$catid}-{$page}.html content-{$c ...

  2. PHPCMS V9二次开发]自定义字段模型-文本组

    phpcms v9,我们在做类似于酒店房型等类型的时候,需要用到文本组字段模型,但phpcms并未提供该模型.如下图所示效果: 展示效果如下: 步骤/方法 打开phpcms\modules\conte ...

  3. [PHPCMS V9二次开发]自定义字段模型-添加字段类型

    步骤/方法 打开phpcms\modules\content\fields目录,复制文件夹downfiles,并改名为textgroups. 打开phpcms\modules\content\fiel ...

  4. phpcms V9 栏目管理

    关于phpcms V9框架系统后台管理之栏目管理,请参见下文的源码分析(添加栏目和修改栏目): 参照添加栏目的界面图示,便于对源代码的理解: <?php // 文件路径:phpcms/modul ...

  5. PHPCMS V9静态化HTML生成设置及URL规则优化

    先讲讲Phpcms V9在后台怎么设置生成静态化HTML,之后再讲解怎么自定义URL规则,进行URL地址优化.在这一篇中,伪静态就不涉及了,大家可以移步到Phpcms V9全站伪静态设置方法. 一.静 ...

  6. (转载)phpcms v9两步实现专题栏目生成路径去掉html和special

    相信很多人都知道,phpcms v9专题是不支持自定义URL的,生成的专题路径是以/HTML/special/开头的.那么如何实现专题栏目生成路径去掉html和special呢?通过修改程序的PHP源 ...

  7. 转载]PhpCms V9调用指定栏目子栏目文章的两种方法

    PhpCms V9调用指定栏目子栏目文章的两种方法 第一种.直接写子栏目id ,用cat in {pc:get sql="SELECT * from v9_news where status ...

  8. phpcms v9 下拉菜单 二级 三级子栏目调用方法

    很多网站的导航栏可以实现下拉二级菜单,三级菜单等效果,今天我们就来分享phpcms v9 支持下拉菜单的方法,可以支持无限子栏目调用,具体写法如下: <ul> {pc:content ac ...

  9. PHPCMS v9栏目添加字段及描述编辑器修改方法

    为PHPCMS v9栏目添加字段和把描述的textarea编辑器变成fceditor编辑器的方法.如下: 1. 添加数据库字段:description1,添加位置:v9_catetory表 2. 在c ...

随机推荐

  1. php 计算gps坐标 距离

    在计算机或GPS上经纬度经常用度.分.秒和度.度.分.分.秒.秒的混合方式进行表示,度.分.秒间的进 制是60进制,度.度.分.分. 秒.秒的进制是100进制,换算时一定要注意.可以近似地认为每个纬度 ...

  2. LayoutInflater的动态增加控件

    在实际开发中LayoutInflater这个类是非常有用的,它的作用类似于 findViewById(),不同点是LayoutInflater是用来找layout下xml布局文件. 而findView ...

  3. Django orm 中 python manage.py makemigrations 和 python manage.py migrate 这两条命令用途

    生成一个临时文件 python manage.py makemigrations 这时其实是在该app下建立 migrations目录,并记录下你所有的关于modes.py的改动,比如0001_ini ...

  4. jQuery -&gt; 使用andSelf()来包括之前的选择集

    版权声明:本文为博主原创文章.转载请注明出处 https://blog.csdn.net/FeeLang/article/details/26254793 当我们使用Destructive Metho ...

  5. 文件传输(xmodem协议)

    https://www.menie.org/georges/embedded/ 需要移植如下两个基础的硬件读写函数 int _inbyte(unsigned short timeout); void ...

  6. C#生成电子印章源码

    using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...

  7. POJ2318:TOYS(叉积判断点和线段的关系+二分)&&POJ2398Toy Storage

    题目:http://poj.org/problem?id=2318 题意: 给定一个如上的长方形箱子,中间有n条线段,将其分为n+1个区域,给定m个玩具的坐标,统计每个区域中的玩具个数.(其中这些线段 ...

  8. C++学习笔记--名称空间

    名称空间是为了更好的控制名称的作用域,以管理不同的类库,避免发生冲突. 1.创建名称空间 如下,使用namespace关键字创建了pers和debts两个名称空间. #ifndef NAMESP_H_ ...

  9. 工作笔记——区块链POC

    1.基础配置 安装SecureCRT 8.0链接到虚拟服务器,并配置docker 安装文件上传到服务器工具FileZilla

  10. flask内置session原理

    内置session原理 请求到来 当请求进来之后,先执行Flask对象的 __call__ 方法 def wsgi_app(self, environ, start_response): # 获取请求 ...