PHPCMS手機站偽靜態設定詳解

來源:互聯網
上載者:User
這篇文章主要介紹了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;

以上就是本文的全部內容,希望對大家的學習有所協助。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.