这里有新鲜出炉的 PHP 教程,程序狗速度看过来!
PHP(外文名: Hypertext Preprocessor,中文名:"超文本预处理器")是一种通用开源脚本语言。语法吸收了 C 语言、Java 和 Perl 的特点,入门门槛较低,易于学习,使用广泛,主要适用于 web 开发领域。PHP 的文件后缀名为 php。
这篇文章主要介绍了 PHPCMS 手机站伪静态设置教程,非常不错,具有参考借鉴价值,需要的朋友可以参考下
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 手机站伪静态设置),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 PHPERZ 网站的支持!
来源: http://www.phperz.com/article/17/0810/340617.html