当前位置:首页 > CMS教程 > phpcms > 列表

PHPCMS手机站伪静态设置详细教程

发布:smiling 来源: PHP粉丝网  添加日期:2018-07-31 11:19:18 浏览: 评论:0 

1、打开/phpcms/modules/wap/functions/global.func.php

找到里面的这两个函数,如下图所示的注释掉的那行代码,在下面加入一行代码。

  1. functionlist_url($typeid) { 
  2.   #returnWAP_SITEURL."&a=lists&typeid=$typeid"; 
  3.   return"/list-$typeid".'.html' 
  4. } 
  5. functionshow_url($catid,$id,$typeid='') { 
  6. global$WAP; 
  7. if($typeid=='') { 
  8.  $types= getcache('wap_type','wap'); 
  9.  <a href="/tags.php/foreach/" target="_blank">foreach</a>($typesas$type) { 
  10.   if($type['cat']==$catid) { 
  11.   $typeid=$type['typeid']; 
  12.   break; 
  13.   } 
  14.  } 
  15. }  
  16.   #returnWAP_SITEURL."&a=show&catid=$catid&typeid=$typeid&id=$id"; 
  17.   return"/show-$catid-$typeid-$id-1".'.html' 
  18. } 

2、打开/phpcms/modules/wap/index.php

找到第59行,如下图所示的注释掉的那行代码,在下面加入一行代码。

  1. #define('URLRULE','index.php?m=wap&c=index&a=lists&typeid={$typeid}~index.php?m=wap&c=index&a=lists&typeid={$typeid}&page={$page}'); 
  2. define('URLRULE','list-{$typeid}.html~list-{$typeid}-{$page}.html'); 
3、添加伪静态规则

我使用的是apache服务器,把apache服务器设置支持.htaccess文件,在网站根目录创建.htaccess文件,在里面添加代码:

  1. RewriteEngine On  
  2. RewriteRule ^list-([0-9]+)-([0-9]+) index.php?&a=lists&typeid=$1&page=$2 
  3. RewriteRule ^list-([0-9]+) index.php?&a=lists&typeid=$1; 
  4. RewriteRule ^show-([0-9]+)-([0-9]+)-([0-9]+) index.php?a=show&catid=$1&typeid=$2&id=$3; 
这样,phpcms手机站就变成伪静态了。
 
.htaccess如何设置和创建可自行百度一下,方法都比较简单,这里就不细说了。

如果是nginx服务器,重写规则这样写:

  1. rewrite ^/list-([0-9]+).html /index.php?&a=lists&typeid=$1last; 
  2. rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+)-1.html /index.php?a=show&catid=$1&typeid=$2&id=$3last; 

Tags: 静态 教程 手机

分享到: