首页 > CMS > 织梦DEDE > 正文

织梦CMS如何配置手机wap站点,并绑定二级域名

2024-07-09 22:52:33
字体:
来源:转载
供稿:网友

dedecms织梦配置手机wap站点,并绑定二级域名 。

1.安装手机wap浏览 模块

2.根目录创建 wap文件夹 ,将 templets/wap 文件移入 根目录下的 wap, 如图:

dedecms 织梦配置 手机 wap 站点,并绑定二级域名

3.将根目录下的 wap.php 移入 wap文件夹,如图:

dedecms 织梦配置 手机 wap 站点,并绑定二级域名

4.修改wap.php

a.   第一行require_once (dirname(__FILE__) . "/include/common.inc.php"); 修改成require_once (dirname(__FILE__) . "/../include/common.inc.php");

b.  第四行require_once(dirname(__FILE__)."/include/wap.inc.php");修改成require_once(dirname(__FILE__)."/../include/wap.inc.php");

c.  第六行 $cfg_templets_dir = $cfg_basedir.$cfg_templets_dir;修改成 $cfg_templets_dir = $cfg_basedir."/wap/".$cfg_templets_dir;

d.  找 到require_once(dirname(__FILE__)."/include/datalistcp.class.php"); 修改成require_once(dirname(__FILE__)."/../include/datalistcp.class.php");

5.文章带有图片处理,找到include/wap.inc.php

第54行 $content = str_replace("WAP-IMG::{$k}", $attstr, $content); 修改成 $content = str_replace("WAP-IMG::{$k}", “”, $content);

如果希望让图片显示,您可以修改这个图片路径

6.IIS设置

a .www.abc.com 下的 wap 文件夹 做重定向

b. 创建新站点 wap.abc.com 绑定文件夹 wap

7. 手机访问www.abc.com  直接跳转 wap.abc.com

模板index.htm 添加js

  1. <script src="/tz.php" type="text/javascript"></script>

tz.php  代码:

  1. <?php 
  2. if(isset($_SERVER['HTTP_USER_AGENT']))
  3. {
  4. $clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront',
  5. 'symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');
  6. // 从HTTP_USER_AGENT中查找手机浏览器的关键字
  7. if (preg_match("/(".implode('|',$clientkeywords).")/i",strtolower($_SERVER['HTTP_USER_AGENT']))){
  8. ?>
  9. <?php 
  10. if(isset($_SERVER['HTTP_USER_AGENT']))
  11. {
  12. $clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront',
  13. 'symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');
  14. // 从HTTP_USER_AGENT中查找手机浏览器的关键字
  15. if (preg_match("/(".implode('|',$clientkeywords).")/i",strtolower($_SERVER['HTTP_USER_AGENT']))){
  16. ?>
  17. window.location.href='http://wap.abc.com';
  18. <?PHP
  19. }
  20. }
  21. ?>

8.wap站添加 搜索

修改 wap.php

  1. else if($action=='search')
  2. {
  3. $needCode = 'UTF-8'; 
  4. if(empty($keyword)) exit('Error!');
  5. require_once(dirname(__FILE__)."/../include/datalistcp.class.php");
  6. $varlist = "cfg_webname,cfg_templeturl";
  7. ConvertCharset($varlist);
  8. $dlist = new DataListCP();
  9. $dlist->SetTemplet($cfg_templets_dir."/wap/search.wml");
  10. $dlist->pageSize = 10;
  11. $dlist->SetParameter("action","search");
  12. $dlist->SetParameter("keyword",$keyword);
  13. $dlist->SetSource("Select id,title,pubdate,click From `idea_archives` where title like '%". iconv("UTF-8", "GB2312",$keyword)."%' And arcrank=0 order by id desc"); 
  14. $dlist->Display();
  15. exit();
  16. }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表