1. 程式人生 > >帝國CMS 手機版制作+帝國PC跳轉到手機+重新定向

帝國CMS 手機版制作+帝國PC跳轉到手機+重新定向

eba -s andro 屬性 sel ocs phone 文件 var

學習鏈接:

帝國CMS7.2版多終端訪問功能使用圖文教程:http://bbs.phome.net/showthread-13-329096-0.html

帝國cms電腦pc站url跳轉到手機站url的方法原文地址:http://www.zzarea.com/cms/diguocms/2153.html

.htaccess技巧: URL重寫(Rewrite)與重定向(Redirect):http://blog.csdn.net/newjueqi/article/details/12014673

帝國手機訪問端制作步驟:


一、設置所有訪問端統一的訪問地址;

系統--系統設置--系統參數設置--基本屬性--修改附件地址為wap端地址

二、新增訪問端使用的模板組;

模板--模板組管理--導入/導出模板組--導入模板組--瀏覽--新建新的模板組--導入--模板組名稱--修改

三、新建訪問端目錄,並復制一份帝國CMS程序文件進去;

上傳到根目錄下(註意事項:不在主端目錄下建子目錄,要註意設置好目錄權限。)

四、給新增的訪問端目錄綁定個二級域名;

解析域名:m.******.com
綁定域名:到主機

五、到主訪問端後臺新增“網站訪問端”;

系統--網站多訪問端--管理網站多訪問端--增加訪問端--:
名稱:手機訪問端
地址:http://m.qyhongyan.com/(或者直接使用路徑:http://www.qyhongyan.com/sjbb/)


目錄:/home/u1025/ace/workspace/php/appcode/webroot/htdocs/sjbb/
密鑰:--隨機生成
使用模板:手機
頁面模式:強制動態
關閉投稿
提交

--更新訪問端緩存

六、到新訪問端目錄修改配置文件參數;

修改配置文件--/sjbb/e/config/config.php

填寫本訪問端使用的模板組ID,以及本網站訪問端ID。比如改為:
手機模板id為2,訪問端手機id為2
$ecms_config[‘sets‘][‘deftempid‘]=2;
$ecms_config[‘sets‘][‘selfmoreportid‘]=2;

七、完成。

在公共模板給一句代碼讓其跳轉到手機訪問:(或者直接給首頁,根據自己需求來,建議只給首頁)
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://www.qyhongyan.com/sjbb/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://www.qyhongyan.com/sjbb/">

方法一:帝國pc站跳轉到手機靜態站

1、假設我們有帝國cms 電腦網站www.zzarea.com,手機網站m.zzarea.com,手機網站使用帝國cms的多訪問端功能制作.現在電腦端和手機端都是生成靜態網站,除了域名不同,靜態連接地址都是相同的,例如:
www.zzarea.com/china/1.html對應 m.zzarea.com/china/1.html

2、接下來要給電腦網站的首頁、列表頁、內容頁的模板添加跳轉代碼,方法如下:
js是瀏覽器跳轉,meta是告訴搜索引擎移動頁面的地址。

(1)首頁模板需添加下面代碼
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.zzarea.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com/">

(2)封面頁和列表頁添加下面代碼
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.zzarea.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com<?=sys_ReturnBqClassUrl($class_r[$GLOBALS[navclassid]]);?>">

(3)內容頁添加下面代碼
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.zzarea.com[!--titleurl--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com[!--titleurl--]">

添加完上面代碼後,帝國cms的電腦網站的每個頁面都可以跳轉到手機靜態網站了。

但手機靜態站是有缺點的,每次我們更新電腦端文章,都要去手機端後臺重新生成一下html,比較麻煩,所以我們可以把手機站設置成動態訪問,接下來就講解一下電腦端跳轉手機動態站的方法。

方法二:帝國cms電腦網站跳轉到手機動態站的方法
1、首先在電腦端的多訪問端設置,把手機端設置成強制動態頁面模式。這樣手機站就是動態了,不用每次都去生成html 。
2、接下來就是給電腦端模板的首頁、列表頁、內容頁添加相依跳轉代碼,和方法一類似。
js是瀏覽器跳轉,meta是告訴搜索引擎移動頁面的地址。
(1)首頁模板需添加下面代碼
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.zzarea.com/";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com/">

(2)封面頁和列表頁添加下面代碼
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.zzarea.com/e/action/ListInfo/?classid=[!--self.classid--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com/e/action/ListInfo/?classid=[!--self.classid--]">

(3)內容頁添加下面代碼
<script type="text/javascript">
try {var urlhash = window.location.hash;if (!urlhash.match("fromapp"))
{if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{window.location="http://m.zzarea.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]";}}}
catch(err)
{
}</script>
<meta name="mobile-agent" content="format=xhtml;url=http://m.zzarea.com/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]">

添加上面代碼後,pc網站就可以跳轉到手機端的對應網頁了。
註意:使用上面代碼時,把代碼中的域名改成你自己的域名就可以了。
原文地址:http://www.zzarea.com/cms/diguocms/2153.html

重新定向應用於:m.****.com

代碼如下:文件後綴--.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^m.qyhongyan.com$ [NC]
RewriteCond %{REQUEST_URI} !^/sjbb/
RewriteRule ^(.*)$ sjbb/$1?Rewrite [L,QSA]
</IfModule>

帝國CMS 手機版制作+帝國PC跳轉到手機+重新定向