《PHP实例:PHPCMS手机站伪静态设置详细教程》要点:
本文介绍了PHP实例:PHPCMS手机站伪静态设置详细教程,希望对您有用。如果有疑问,可以联系我们。
相关主题:PHPCMS教程
PHP编程1、打开/phpcms/modules/wap/functions/global.func.php
PHP编程找到里面的这两个函数,如下图所示的注释掉的那行代码,在下面加入一行代码.
- 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';
- }
PHP编程2、打开/phpcms/modules/wap/index.php
PHP编程找到第59行,如下图所示的注释掉的那行代码,在下面加入一行代码.
- PHP编程
- #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');
PHP编程3、添加伪静态规则
PHP编程我使用的是apache服务器,把apache服务器设置支持.htaccess文件,在网站根目录创建.htaccess文件,在里面添加代码:
PHP编程RewriteEngine On
- PHP编程
- 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;
PHP编程这样,phpcms手机站就变成伪静态了.
PHP编程.htaccess如何设置和创建可自行百度一下,方法都比较简单,这里就不细说了.
PHP编程如果是nginx服务器,重写规则这样写:
- PHP编程
- 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;
PHP编程以上所述是小编给大家介绍的PHPCMS手机站伪静态设置),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的.在此也非常感谢大家对维易PHP网站的支持!
转载请注明本页网址:
http://www.vephp.com/jiaocheng/1867.html