以下适用于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. return false与return true的区别

    <a href="http://www.baidu.com" onclick="alert(11);return true;alert(22)">链 ...

  2. linux No space left on device 由索引节点(inode)爆满引发500问题

    inode是什么? 理解inode,要从文件储存说起. 文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector).每个扇区储存512字节(相当于0.5KB). 操作系统读取 ...

  3. 记录python接口自动化测试--利用unittest生成测试报告(第四目)

    前面介绍了是用unittest管理测试用例,这次看看如何生成html格式的测试报告 生成html格式的测试报告需要用到 HTMLTestRunner,在网上下载了一个HTMLTestRunner.py ...

  4. C语言博客作业--字符数组

    一.PTA实验作业 题目1:统计一行文本的单词个数 1. 本题PTA提交列表 2. 设计思路 Begin 定义字符型变量ch,pre=' ': 定义整型变量count://用来记录单词个数 count ...

  5. 第五次作业-需求&原型改进

    需求&原型改进 0. 团队介绍 团队名称:121ComeOn 项目名称:个人博客项目 团队组成: PM:黄金筱(107) 成员:王枫(031),刘烨(255),周明浩(277) github地 ...

  6. 一些琐碎的C/C++知识点

    1. C++ 数组作为函数参数 在C/C++中,当数组作为函数的参数进行传递时,数组就自动退化为同类型的指针.(在32位系统中,对任意指针求sizeof结果为4) 2. C++ 中const的用法总结 ...

  7. C语言总结报告

    1.当初你是如何做出选择计算机专业的决定的? 经过一个学期,你的看法改变了么,为什么? 你觉得计算机是你喜欢的领域吗,它是你擅长的领域吗? 为什么? 当初报考计算机专业,是看到计算机专业在当今社会有良 ...

  8. iOS开发之UITextView,设置textViewplaceholder

    一.设置textView的placeholder UITextView上如何加上类似于UITextField的placeholder呢,其实在UITextView上加上一个UILabel或者UITex ...

  9. vue mint-ui 三级地址联动

    我也是第一次写这种地址联动的 刚开始的时候 我还以为直接用select来写 后来公司的ios告知并不是这样的 他说应该时这样的 于是第一想法 赶紧找插件吧 但是找了一会未果  就问了公司大神 他刚开始 ...

  10. Lock(三)查看是谁把表给锁了

    查看是谁把表给锁了 select se1.inst_id as 被阻塞的会话节点, se2.inst_id as 罪魁祸首节点, se1.sid as 被阻塞的会话ID, ob.object_name ...