当前位置: 移动技术网 > IT编程>开发语言>PHP > PHPCMS手机站伪静态设置详细教程

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

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服务器,把apache服务器设置支持.htaccess文件,在网站根目录创建.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; 

这样,phpcms手机站就变成伪静态了。

.htaccess如何设置和创建可自行百度一下,方法都比较简单,这里就不细说了。

如果是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手机站伪静态设置),希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网