共計 5227 個字符,預計需要花費 14 分鐘才能閱讀完成。
杰奇 cms2.4 這個偽靜態設置教程,相對于二次開發那些,這個確實是算簡單的了。 只需要根據網上的 js 自己補充而已,但是相對于每個模板都配置一條跳轉規則,我還是有個簡單的辦法,不過還是得配合已經設置好的偽靜態。在這篇教程里,小編就簡單說明一下杰奇 CMS 電腦和手機端兩邊的配置。
比較重要的頁面主要是首頁,書庫,分類,小說信息,充值,目錄,小說閱讀,但是一般來說目錄和小說閱讀的頭部是放置在單個文件中,不和其它頁面共用。
假如:
電腦端網址為:pc.xx.com
手機端網址為:wap.xx.com
教程開始:
1、首先是 PC 端的修改
1. 在 PC 端的 /themes/ 目錄中找到當前設置的模板,進入后找到 theme.html,在它的 head 標簽對中加入如下代碼:
<script?type="text/javascript">??????
function?browserRedirect()?{
??var?sUserAgent?=?navigator.userAgent.toLowerCase();
??var?bIsIpad?=?sUserAgent.match(/ipad/i)?==?"ipad";
??var?bIsIphoneOs?=?sUserAgent.match(/iphone?os/i)?==?"iphone?os";
??var?bIsMidp?=?sUserAgent.match(/midp/i)?==?"midp";
??var?bIsUc7?=?sUserAgent.match(/rv:1.2.3.4/i)?==?"rv:1.2.3.4";
??var?bIsUc?=?sUserAgent.match(/ucweb/i)?==?"ucweb";
??var?bIsAndroid?=?sUserAgent.match(/android/i)?==?"android";
??var?bIsCE?=?sUserAgent.match(/windows?ce/i)?==?"windows?ce";
??var?bIsWM?=?sUserAgent.match(/windows?mobile/i)?==?"windows?mobile";
??if(bIsIphoneOs?||?bIsMidp?||?bIsUc7?||?bIsUc?||?bIsAndroid?||?bIsCE?||?bIsWM){
??{?if?$jieqi_thisfile|basename?==?'articlefilter.php'?}
??window.location.href?=?"http://wap.xx.com/modules/article/articlefilter.php";
??{?else?if?$jieqi_thisfile|basename?==?'articlelist.php'?}
??window.location.href?=?"http://wap.xx.com/sort/{?$sortid?}/1.html";
??{?else?if?$jieqi_thisfile|basename?==?'buyegold.php'?}
??window.location.href?=?"http://wap.xx.com/modules/pay/buyegold.php";
??{?else?if?$jieqi_thisfile|basename?==?'articleinfo.php'?}
??window.location.href?=?"http://wap.xx.com/book/{?$articleid?}";
??{?else?}
??window.location.href?=?"http://wap.xx.com/";
??{?/if?}
??}
}
browserRedirect();
</script>
2. 目錄頁和章節頁頭部可能在 themer.html,也可能是 /modules/article/templates/ 里面的 style.html 和 index.html,同樣是在 head 標簽對加入如下代碼。
<script?type="text/javascript">??????
function?browserRedirect()?{
??var?sUserAgent?=?navigator.userAgent.toLowerCase();
??var?bIsIpad?=?sUserAgent.match(/ipad/i)?==?"ipad";
??var?bIsIphoneOs?=?sUserAgent.match(/iphone?os/i)?==?"iphone?os";
??var?bIsMidp?=?sUserAgent.match(/midp/i)?==?"midp";
??var?bIsUc7?=?sUserAgent.match(/rv:1.2.3.4/i)?==?"rv:1.2.3.4";
??var?bIsUc?=?sUserAgent.match(/ucweb/i)?==?"ucweb";
??var?bIsAndroid?=?sUserAgent.match(/android/i)?==?"android";
??var?bIsCE?=?sUserAgent.match(/windows?ce/i)?==?"windows?ce";
??var?bIsWM?=?sUserAgent.match(/windows?mobile/i)?==?"windows?mobile";
??if(bIsIphoneOs?||?bIsMidp?||?bIsUc7?||?bIsUc?||?bIsAndroid?||?bIsCE?||?bIsWM){
??{?if?$jieqi_thisfile|basename?==?'reader.php'?}
??window.location.href?=?"http://wap.xx.com/index/{?$articleid?}/1/asc";
??{?else?if?$chapterid?!=?''?}
??window.location.href?=?"http://wap.xx.com/book/{?$articleid?}/{?$chapterid?}.html";
??{?else?}
??window.location.href?=?"http://wap.xx.com/";
??{?/if?}
??}
}
browserRedirect();
</script>
2、然后是 WAP 端的修改:
1. 在 WAP 端的 /themes/ 目錄中找到當前設置的模板,進入后找到 theme.html,在它的 head 標簽對中加入如下代碼:
<script>
??if(?navigator.userAgent.match(/Android/i)
?????||?navigator.userAgent.match(/webOS/i)
?????||?navigator.userAgent.match(/iPhone/i)
?????||?navigator.userAgent.match(/iPad/i)
?????||?navigator.userAgent.match(/iPod/i)
?????||?navigator.userAgent.match(/BlackBerry/i)
?????||?navigator.userAgent.match(/Windows?Phone/i)
????){
??}else{
??{?if?$jieqi_thisfile|basename?==?'articlefilter.php'?}
??window.location.href?=?"http://pc.xx.com/modules/article/articlefilter.php";
??{?else?if?$jieqi_thisfile|basename?==?'articlelist.php'?}
??window.location.href?=?"http://pc.xx.com/sort/{?$sortid?}/1.html";
??{?else?if?$jieqi_thisfile|basename?==?'buyegold.php'?}
??window.location.href?=?"http://pc.xx.com/modules/pay/buyegold.php";
??{?else?if?$jieqi_thisfile|basename?==?'articleinfo.php'?}
??window.location.href?=?"http://pc.xx.com/book/{?$articleid?}";
??{?else?}
??window.location.href?=?"http://pc.xx.com/";
??{?/if?}
??}
</script>
2. 目錄頁和章節頁和 pc 差不多相同,一樣的邏輯,就是目錄頁面的細節不一樣。
<script>
??if(?navigator.userAgent.match(/Android/i)
?????||?navigator.userAgent.match(/webOS/i)
?????||?navigator.userAgent.match(/iPhone/i)
?????||?navigator.userAgent.match(/iPad/i)
?????||?navigator.userAgent.match(/iPod/i)
?????||?navigator.userAgent.match(/BlackBerry/i)
?????||?navigator.userAgent.match(/Windows?Phone/i)
????){
??}else{
??{?if?$jieqi_thisfile|basename?==?'reader.php'?}
??window.location.href?=?"http://pc.xx.com/index/{?$articleid?}";
??{?else?if?$chapterid?!=?''?}
??window.location.href?=?"http://pc.xx.com/book/{?$articleid?}/{?$chapterid?}.html";
??{?else?}
??window.location.href?=?"http://pc.xx.com/";
??{?/if?}
??}
</script>
3、杰奇后臺偽靜態的設置
沒寫的自己按照格式寫偽靜態規則,或者不填。
小說信息頁面偽靜態規則:/book/<{$id}>
小說分類頁面偽靜態規則:/sort/<{$sortid}>/<{$page}>.html
排行榜頁面偽靜態規則:/top/<{$order}>/<{$page}>.html
書庫偽靜態規則:/book_<{$order}>_<{$rgroup}>_<{$sortid}>_<{$typeid}>_<{$words}>_<{$update}>_<{$initial}>_<{$isfull}>_<{$isvip}>_<{$page}>.html
小說目錄頁偽靜態規則:/index/<{$aid}>
小說章節頁偽靜態規則:/book/<{$aid}>/<{$cid}>.html
搜索結果頁偽靜態規則:/search/<{$searchtype}>/<{$searchkey}>/<{$page}>.html
搜索結果頁偽靜態規則:/reviews/<{$aid}>/<{$page}>.html
標簽列表頁偽靜態規則:/taglist/<{$sort}>/<{$page}>.html
apache 偽靜態,在根目錄創建.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^templates/(.*).html$ /404.php
RewriteRule ^themes/(.*)/(.*).html$ /404.php
RewriteRule ^modules/(.*)/templates/$ /404.php
RewriteRule ^modules/(.*)/templates/(.*).html$ /404.php
RewriteRule ^book/([0-9]+)$ /modules/article/articleinfo.php?id=$1