QQ咨询 官方微信

添加微信好友

官方小程序

百度小程序

微信小程序

头条小程序

关于我们

PHPCMS

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

 admin  2022-06-03 19:33:51
1、打开/phpcms/modules/wap/functions/global.func.php

找到里面的这两个函数,如下图所示的注释掉的那行代码,在下面加入一行代码。
  1. function list_url($typeid) { 
  2.   #return WAP_SITEURL."&a=lists&typeid=$typeid"; 
  3.   return "/list-$typeid".'.html'
  4. function show_url($catid, $id, $typeid='') { 
  5. global $WAP; 
  6. if($typeid=='') { 
  7. $types = getcache('wap_type','wap'); 
  8. foreach ($types as $type) { 
  9.   if($type['cat']==$catid) { 
  10.   $typeid = $type['typeid']; 
  11.   break
  12.   } 
  13. }  
  14.   #return WAP_SITEURL."&a=show&catid=$catid&typeid=$typeid&id=$id"; 
  15.   return "/show-$catid-$typeid-$id-1".'.html'

2、打开/phpcms/modules/wap/index.php

找到第59行,如下图所示的注释掉的那行代码,在下面加入一行代码。
  1. #define('URLRULE', 'index.php?m=wap&c=index&a=lists&typeid={$typeid}~index.php?m=wap&c=index&a=lists&typeid={$typeid}&page={$page}'); 
  2. define('URLRULE''list-{$typeid}.html~list-{$typeid}-{$page}.html'); 


3、添加伪静态规则

我使用的是apache服务器,把apache服务器设置支持.htaccess文件,在网站根目录创建.htaccess文件,在里面添加代码:

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

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

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

如果是nginx服务器,重写规则这样写:

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

¥ 打赏
×
如果您觉得文章帮助了您就打赏一下吧
非常感谢你的打赏,我们将继续分享更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

本文《PHPCMS手机站伪静态设置详细教程》发布于石头博客文章,作者:admin,如若转载,请注明出处:https://www.pweb123.com/cms/phpcms/742.html,否则禁止转载,谢谢配合!

文章点评

我来说两句 已有0条评论
点击图片更换

添加微信好友

添加微信好友

微信小程序

百度小程序