PHPCMS开发

当前位置/ 首页/ V9教程/PHPCMS开发/ 正文

实现PHPCMS手机门户的伪静态链接

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

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

function list_url($typeid) {
    #return WAP_SITEURL."&a=lists&typeid=$typeid";
    return "/list-$typeid".'.html';
}



function show_url($catid, $id, $typeid='') {
global $WAP;
if($typeid=='') {
  $types = getcache('wap_type','wap');
  foreach ($types as $type) {
   if($type['cat']==$catid) {
    $typeid = $type['typeid'];
    break;
   }
  }
}  
    #return WAP_SITEURL."&a=show&catid=$catid&typeid=$typeid&id=$id";
    return "/show-$catid-$typeid-$id-1".'.html';
}

2、打开/phpcms/modules/wap/index.php
找到第59行,如下图所示的注释掉的那行代码,在下面加入一行代码。

 

#define('URLRULE', 'index.php?m=wap&c=index&a=lists&typeid={$typeid}~index.php?m=wap&c=index&a=lists&typeid={$typeid}&page={$page}');

define('URLRULE', 'list-{$typeid}.html~list-{$typeid}-{$page}.html');

3、添加伪静态规则

 

apache服务器:打开根目录的权限文件,添加如下代码

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

 nginx服务器:添加如下URL重写规则

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

进入后台更新缓存》生成首页就实现了PHPCMS手机门户的伪静态链接了。