以下适用于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. xampp配置多端口访问

    1.修改D:\xampp\apache\conf\extra中的httpd-vhosts.conf文件,在最底部添加 <VirtualHost *:8080> ##需要监听的端口号 Ser ...

  2. HTTP 0.9 HTTP 1.0 HTTP 1.1 HTTP 2.0区别

    HTTP协议 :Hyper Text Transfer Protocol(超文本传输协议),是用于从万维网(WWW:World Wide Web)服务器传输超文本到本地浏览器的传送协议.是互联网上应用 ...

  3. Matplotlib库的使用

    *可通过dpi修改输出质量 plot函数 第一种方法会使图中所有的字体改变,而第二种方法只会改变中文字体,推荐使用第二种方法.

  4. spring-boot-devtools

    Create a new Maven Project  and  we have two class under the package com.example.demo like below scr ...

  5. The Beginning of the Graph Theory

    The Beginning of the Graph Theory 是的,这不是一道题.最近数论刷的实在是太多了,我要开始我的图论与树的假期生活了. 祝愿我吧??!ShuraK...... poj18 ...

  6. 四十六、android中的Bitmap

    四十六.android中的Bitmap: http://www.cnblogs.com/linjiqin/archive/2011/12/28/2304940.html 四十七.实现调用Android ...

  7. 微信小程序中实现微信支付

    最近在做微信小程序,今天刚好做到小程序里的微信支付这块,踩过不少坑,特此写个博客记录下,希望能帮到其它人吧. 我总结了一下,小程序中的微信支付和之前其它的公众号里的微信支付有两个区别,第一就是小程序必 ...

  8. 浅谈RMQ

    RMQ是一类求区间极值的问题 有一种 \(O\left(nlogn\right)\) 的解法,用倍增实现 倍增算法 变量的定义 \(A_i\) : 原数组 \(f_{i,j}\) : 以 \(i\) ...

  9. electron-vue工程创建

    没有vue创建经验请移步至 vue下载与安装 使用vue创建electron-vue工程 vue init simulatedgreg/electron-vue my-project 安装elemen ...

  10. 网页设计入门<一>

    俗话说:技多不压身.实习周,网页设计是之一,边学边总结... 本次网页设计基于Adobe Dreamweaver CS6开发平台,根据实习老师的暴力指导,为什么说暴力呢? 没有基础,没有预告,打开软件 ...