大家知道,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='')这两个关于页面网址的函数,修改如下图所示的注释掉的那行代码:
具体代码:
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思优团队的文章有疑问,那就在下面评论留言吧!
点击加载更多