drfkl66684 2014-07-29 11:42
浏览 31

如何将移动网站用户重定向到移动布局

I can't find some solid information on what I'm specifically looking for, nor do I know the best method of doing this (in code or using HTACCESS); to redirect mobile users to http://m.example.com

I am looking to enable both mobile, and PC users to view our website in both devices, with a user-friendly layout to accommodate for both users.

  • 写回答

2条回答 默认 最新

  • douyi3307 2014-07-29 11:46
    关注

    The solution without HTACCESS:

    Best way is store the info about which layout is selected in Cookie.

    if(isset($_GET["setMobile"])) {
      setcookie("m", $_GET["setMobile"], time()+(60*60*24*31), "/");
    }
    

    And then

    if($_COOKIE["m"]) {
      /* MOBILE LAYOUT */
    }
    

    I thnk you do not even Need htaccess. You can create index.php in your subfolder m.domain.com and place there Cookie Definition.

    setcookie("m", true, time()+(60*60*24*31), "/");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程