最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHPCMS手机站伪静态设置详细教程
时间:2022-06-24 14:57:25 编辑:袖梨 来源:一聚教程网
1、打开/phpcms/modules/wap/functions/global.func.php
找到里面的这两个函数,如下图所示的注释掉的那行代码,在下面加入一行代码。
| 代码如下 | 复制代码 |
functionlist_url($typeid) { #returnWAP_SITEURL."&a=lists&typeid=$typeid"; return"/list-$typeid".'.html' } functionshow_url($catid,$id,$typeid='') { global$WAP; if($typeid=='') { $types= getcache('wap_type','wap'); foreach($typesas$type) { if($type['cat']==$catid) { $typeid=$type['typeid']; break; } } } #returnWAP_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=$1last; rewrite ^/show-([0-9]+)-([0-9]+)-([0-9]+)-1.html /index.php?a=show&catid=$1&typeid=$2&id=$3last; | |
相关文章
- 无尽花界诸神角色图鉴 无尽花界阵营角色详细介绍 05-08
- 驯龙之旅兑换码大全 驯龙之旅最新可用礼包码汇总 05-08
- 曲奇云盘怎么保存别人分享的文件 05-08
- 末世避难所手游新手入门指南 末世避难所手游零基础快速上手教程 05-08
- 六道轮回手游上线时间揭晓 六道轮回手游正式开服日期分享 05-08
- 无限暖暖埋骨地10个冥想点位一览 05-08