《PHP實(shí)例:PHPCMS手機(jī)站偽靜態(tài)設(shè)置詳細(xì)教程》要點(diǎn):
本文介紹了PHP實(shí)例:PHPCMS手機(jī)站偽靜態(tài)設(shè)置詳細(xì)教程,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
相關(guān)主題:PHPCMS教程
PHP編程1、打開/phpcms/modules/wap/functions/global.func.php
PHP編程找到里面的這兩個(gè)函數(shù),如下圖所示的注釋掉的那行代碼,在下面加入一行代碼.
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、添加偽靜態(tài)規(guī)則
PHP編程我使用的是apache服務(wù)器,把a(bǔ)pache服務(wù)器設(shè)置支持.htaccess文件,在網(wǎng)站根目錄創(chuàng)建.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手機(jī)站就變成偽靜態(tài)了.
PHP編程.htaccess如何設(shè)置和創(chuàng)建可自行百度一下,方法都比較簡(jiǎn)單,這里就不細(xì)說了.
PHP編程如果是nginx服務(wù)器,重寫規(guī)則這樣寫:
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手機(jī)站偽靜態(tài)設(shè)置),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的.在此也非常感謝大家對(duì)維易PHP網(wǎng)站的支持!
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/1867.html