>  기사  >  백엔드 개발  >  PHPCMS 모바일 사이트의 의사정적 설정에 대한 자세한 설명

PHPCMS 모바일 사이트의 의사정적 설정에 대한 자세한 설명

墨辰丷
墨辰丷원래의
2018-05-26 13:58:002049검색

这篇文章主要介绍了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;

以上就是本文的全部内容,希望对大家的学习有所帮助。


相关推荐:

php中cms实现配置列表页以及获得文章发布时间的方法

CMSPRESS实现无限级分类(附代码)

phpcms搜索功能实现

위 내용은 PHPCMS 모바일 사이트의 의사정적 설정에 대한 자세한 설명의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.