PHPCMS开发

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

解决phpcms wap手机站伪静态方法nginx

phpcms开启伪静态的方法很简单,网上的教程特别的多。先将移动版的域名绑定到空间上,然后在phpcms模块里面后台开启手机门户,将移动版域名填进去

打开/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".'.html';
}
添加伪静态规则,这里我使用的是nginx的规则,如果你用的不一样请对照修改。
 
rewrite ^/list-([0-9]+).html /index.php?&a=lists&typeid=$1;
rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+).html /index.php?a=show&catid=$1&typeid=$2&id=$3;
最后的URL就是http://m.xx.com/list-1.html,http://m.xx.com/show-23-7-151.html 这种的,使用手机输入http://m.zzqirui.com/可以预览效果。移动版网站修改了半天也把模板做好了做成移动适配版的了,修改模板的位置在templates目录下面的wap目录。不过感觉phpcms的移动站功能还是有点太简陋了,不太方便做pc移动的URL一一对应跳转。
 
这样那个就解决phpcms wap手机站伪静态方法nginx