溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

PHPCMS手機(jī)站偽靜態(tài)設(shè)置的示例分析

發(fā)布時(shí)間:2021-07-30 13:55:00 來源:億速云 閱讀:99 作者:小新 欄目:開發(fā)技術(shù)

這篇文章主要介紹PHPCMS手機(jī)站偽靜態(tài)設(shè)置的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

1、打開/phpcms/modules/wap/functions/global.func.php

找到里面的這兩個(gè)函數(shù),如下圖所示的注釋掉的那行代碼,在下面加入一行代碼。

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、添加偽靜態(tài)規(guī)則

我使用的是apache服務(wù)器,把a(bǔ)pache服務(wù)器設(shè)置支持.htaccess文件,在網(wǎng)站根目錄創(chuàng)建.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手機(jī)站就變成偽靜態(tài)了。

.htaccess如何設(shè)置和創(chuàng)建可自行百度一下,方法都比較簡(jiǎn)單,這里就不細(xì)說了。

如果是nginx服務(wù)器,重寫規(guī)則這樣寫:

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手機(jī)站偽靜態(tài)設(shè)置的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI