以下适用于PC跳转到ectouch手机版的写法。其他手机端的方法类似。

修改文件 includes/lib_main.php 增加以下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
 * <a href="http://www.uuecs.com/" target="_blank" title="ecshop"><strong class="keylink">ecshop</strong></a> 实现其他页面(商品详情页、商品分类页、<a href="http://www.uuecs.com/tag-tuangou.html" target="_blank" title="团购"><strong class="keylink">团购</strong></a>页、优惠活动页、积分商城)
 * 判断如果是智能<a href="http://www.uuecs.com/shouji/" target="_blank" title="手机"><strong class="keylink">手机</strong></a>访问的话 跳转到<a href="http://www.uuecs.com/shouji" target="_blank" title="Ectouch"><strong class="keylink">Ectouch</strong></a>1.0<a href="http://www.uuecs.com/shouji/" target="_blank" title="手机"><strong class="keylink">手机</strong></a>版对应页面 方法
 *
 * @access  public
 */
function pc_to_mobile()
{
    //判断是否是<a href="http://www.uuecs.com/shouji/" target="_blank" title="手机"><strong class="keylink">手机</strong></a>访问
    $is_mobile = false;
    $ua strtolower($_SERVER['HTTP_USER_AGENT']);
    $uachar "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";
   
    if(($ua == '' || preg_match($uachar$ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
    {
        $is_mobile = true;
    }
   
    /* 判断是否重写,取得文件名 */
    $cur_url basename(PHP_SELF);
    if (intval($GLOBALS['_CFG']['rewrite'])){
        $filename strpos($cur_url,'-') ? substr($cur_url, 0, strpos($cur_url,'-')) : substr($cur_url, 0, -4);
    }else{
        $filename substr($cur_url, 0, -4);
    }
   
    if($is_mobile){
        /*
         * 如果你绑定了手机版域名 http://www.uuecs.com/mobile 为 http://m.abc.com
         * 那么 $mobile_url = http://m.uuecs.com
         */
        $mobile_url $GLOBALS['ecs']->url().'mobile';
   
        /* 根据文件名分别处理中间的部分 */
        if ($filename != 'index')
        {
            /* 处理有分类的 */
            if (in_array($filenamearray('category''goods''brand')))
            {
                /* 商品分类或商品 */
                if ('category' == $filename || 'goods' == $filename || 'brand' == $filename)
                {
                    $Loaction $mobile_url .'/?c='.$filename.'&a=index&'.$_SERVER["QUERY_STRING"];
                }
            }
            /* 处理无分类的 */
            else
            {
                /* <a href="http://www.uuecs.com/tag-tuangou.html" target="_blank" title="团购"><strong class="keylink">团购</strong></a> */
                if ('group_buy' == $filename)
                {
                    if(!empty($_GET['id'])){
                        $Loaction $mobile_url .'/?c=groupbuy&a=info&id='.$_GET['id'];
                    }else{
                        $Loaction $mobile_url .'/?c=groupbuy';
                    }
                }
                /* 拍卖 */
                elseif ('auction' == $filename)
                {
                    if(!empty($_GET['id'])){
                        $Loaction $mobile_url .'/?c=auction&a=info&id='.$_GET['id'];
                    }else{
                        $Loaction $mobile_url .'/?c=auction';
                    }
                }
                /* 夺宝 */
                elseif ('snatch' == $filename)
                {
                    if(!empty($_GET['id'])){
                        $Loaction $mobile_url .'/?c=snatch&a=info&id='.$_GET['id'];
                    }else{
                        $Loaction $mobile_url .'/?c=snatch';
                    }
                }
                /* 批发 */
                elseif ('wholesale' == $filename)
                {
                    if(!empty($_GET['id'])){
                        $Loaction $mobile_url .'/?c=wholesale&a=info&id='.$_GET['id'];
                    }else{
                        $Loaction $mobile_url .'/?c=wholesale';
                    }
                }
                /* 积分兑换 */
                elseif ('exchange' == $filename)
                {
                    if(!empty($_GET['id'])){
                        $Loaction $mobile_url .'/?c=exchange&a=exchange_goods&gid='.$_GET['id'];
                    }else{
                        $Loaction $mobile_url .'/?c=exchange';
                    }
                }
                /* 优惠活动 */
                elseif ('activity' == $filename)
                {
                    $Loaction $mobile_url .'/?c=activity';
                }
   
            }
            /* <a href="http://www.uuecs.com/" target="_blank" title="ecshop"><strong class="keylink">ecshop</strong></a>跳转到手机对应页面 */
            if (!empty($Loaction)){
                ecs_header("Location: $Loaction");
                exit;
            }
        }
   
    }
   
}

随后在 includes/init.php  增加到最底部 ?>前即可。

1
pc_to_mobile();

ecshop PC版本智能跳转到对应手机版页面的更多相关文章

  1. ecshop其他页面判断是智能手机访问也跳转到ECTouch对应手机版页面(转)

    ecshop 其他页面(商品详情页.商品分类页.团购页.优惠活动页.积分商城) 判断如果是智能手机访问跳转到ECTouch1.0手机版对应页面 方法 首先在ecshop 根目录下 includes/l ...

  2. 手机访问pc版网站自动跳转为手机版页面

    1.PC版首页</head>标签前加上以下脚本 <script src="/tools/browser_redirect.ashx"></script ...

  3. 手机访问PC网站自动跳转到手机网站代码(转)

    4G时代,手机网站已经非常普遍了,一般手机网站都有一个二级域名来访问,比如 m.16css.com 如果手机直接访问www.16css.com 就是PC网站,在手机上浏览电脑版网站体验非常不好. 如果 ...

  4. Nginx学习总结(2)——Nginx手机版和PC电脑版网站配置

    考虑到网站的在多种设备下的兼容性,有很多网站会有手机版和电脑版两个版本.访问同一个网站URL,当服务端识别出用户使用电脑访问,就打开电脑版的页面,用户如果使用手机访问,则会得到手机版的页面. 1.判断 ...

  5. PC网站转换成手机版

    博客地址:https://www.cnblogs.com/zxtceq/p/5714606.html 一天完成把PC网站改为自适应!原来这么简单! http://www.webkaka.com/blo ...

  6. apache通过.htaccess(rewrite)判断手机电脑跳转-手机用户重定向到手机版

    自动判断.重定向的办法也有几种: 使用网站构建的程序(例如PHP)来判断.重定向:使用服务器上的Web服务(例如Apache)来判断.重定向. 在Apache中设置重定向有两个办法: 在网站的http ...

  7. DTcms手机版使用余额支付 提示信息跳转到PC版的错误。以及提交订单不打开新页面

    手机版使用余额支付 提示信息跳转到PC版的错误 引起错误的原因是中间需要提交到DTcms.Web\api\payment\balance\index.aspx去处理 导致BasePage.cs中的li ...

  8. JS实现手机访问pc网址自动跳转到wap网站

    之前写pc端直接跳转wap端一直是后端java写的,跟js一样都是根据navigator.userAgent来判断设备是电脑还是手机的,我知道这种前端也可已完成的功能,只是后台比较强势,本人本着以和为 ...

  9. 微信机器人 返现机器人 pc版本 移动版本 java开发 小范省钱

    微信机器人 返现机器人 pc版本 移动版本 java开发 小范省钱 微信搜索微信号 fanli-x 或 扫描下方二维码,可查看效果. 非web版微信,pc/移动版微信 支持新号24小时 不封号! 有任 ...

随机推荐

  1. Node.JS开发环境准备

    1.安装Nodejs的Windows包. 官网:http://nodejs.org/ 2.可以使用cmd运行nodejs项目,命令格式: node  文件名.js node  文件名 3.对于不熟悉的 ...

  2. 工厂模式的进阶复习(Factory)

    工厂模式进阶复习 看了多遍的工厂模式,老是忘记不同模式有什么区别,本文重点说明一下工厂模式的三种方式(简单工厂模式,工厂方法模式,抽象工厂模式)的区别 1.简单工厂模式 简单工厂模式通过Factory ...

  3. 数据库 --> sqlite3之api使用

    创建 if [ ! -d /opt/dbspace ] then mkdir /opt/dbspace fi if [ -f /opt/dbspace/.memo.db ] then rm /opt/ ...

  4. 如何让shell脚本自杀

    有些时候我们写的shell脚本中有一些后台任务,当脚本的流程已经执行到结尾处并退出时,这些后台任务会直接挂靠在init/systemd进程下,而不会随着脚本退出而停止. 例如: [root@maria ...

  5. iOS scrollView中嵌套多个tabeleView处理方案

    项目中经常会有这样的需求,scrollView有个头部,当scrollView滚动的时候头部也跟着滚动,同时头部还有一个tab会锁定在某个位置,scrollView中可以放很多不同的view,这些vi ...

  6. PHP 密码重置,发送邮件,随机长度字母数字密码

    <?php include ("database.php"); require_once ('email.class.php'); date_default_timezone ...

  7. 语句in

    Python :in在for中: for name  in names: names='1','2','3','4','5' for name in names: print(names) in no ...

  8. python 函数 装饰器的使用方法

    一.装饰器  首先,我们要了解到什么是开放封闭式原则? 软件一旦上线后,对修改源代码是封闭的,对功能的扩张是开放的,所以我们应该遵循开放封闭的原则. 也就是说:我们必须找到一种解决方案,能够在不修改一 ...

  9. java基础笔记(2)----流程控制

    java流程控制结构包括顺序结构,分支结构,循环结构. 顺序结构: 程序从上到下依次执行,中间没有任何判断和跳转. 代码如下: package com.lvsling.test; public cla ...

  10. Java虚拟机之类加载机制

    ⑴背景   Java虚拟机把Class文件加载到内存中,并对数据进行校验,转换解析,和初始化,最终形成被虚拟机直接使用的Java类型,这就是类加载机制. ⑵Jvm加载Class文件机制原理 类的生命周 ...