php 可静态 cms,Phpcms V9自带WAP伪静态自定义方法

大家知道,Phpcms自带WAP手机模块调用的网址是动态的,比如我们CMSYOU的默认手机版m.cmsyou.com的列表页和内容页网址是这样的:

http://m.cmsyou.com/index.php?&a=lists&typeid=7

http://m.cmsyou.com/index.php?&a=show&catid=16&typeid=5&id=111

今天在这里CMSYOU参考Phpcms PC版默认的伪静态的方式,与大家分享一种Phpcms自带WAP伪静态自定义方法:

1、修改phpcms/modules/wap/functions/global.func.php,找到里面的list_url($typeid)、show_url($catid, $id, $typeid='')这两个关于页面网址的函数,修改如下图所示的注释掉的那行代码:

6e1b454ba640a6fdc801d3e67df6d7cf.png

具体代码:

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'...这一行代码,在下面加入一行代码:

//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、添加伪静态规则

3.1、如果是apache服务器,修改具体的伪静态.htaccess文件,添加具体的伪静态规则:

RewriteEngine On

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;

3.2、如果是nginx服务器,伪静态规则:

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自带的WAP则可以实现伪静态网址了。

最后,欢迎大家收听CMSYOU官方微博,看完CMSYOU思优团队的文章有疑问,那就在下面评论留言吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值