简体   繁体   English

如何从移动网站重定向到完整网站?

[英]How to redirect from mobile website to full site?

I was trying to figured out how to redirect from my mobile website to full site. 我试图弄清楚如何从移动网站重定向到完整网站。 When I create a button eg: "View Full Site" - it did not go to the full site, instead it go back to mobile website. 当我创建一个按钮时,例如:“查看完整站点”-它没有转到完整站点,而是回到了移动网站。 I use Google Code: http://code.google.com/p/phpmobilizer/ to convert from normal website to mobile site. 我使用Google代码: http : //code.google.com/p/phpmobilizer/从普通网站转换为移动网站。 I was wondering if you know some php code that can redirect from mobile site to full site? 我想知道您是否知道一些可以从移动网站重定向到完整网站的php代码?

Here is the site I am currently working on http://www.roofpro.ca 这是我目前正在http://www.roofpro.ca上使用的网站

Thanks! 谢谢! Christie 佳士得

Just set a session if the user wants to go from mobile to desktop version. 如果用户想从移动版转到桌面版,只需设置一个会话即可。 Do like this: 这样做:

<a href="/index.php?goToDesktop=1">Go to desktop version</a>

Then, at the top of your index.php file: 然后,在index.php文件的顶部:

<?php
session_start();
if ($_GET['goToDesktop'] == 1)
{
  $_SESSION['desktop'] = 1;
}

// then in your auto-mobile-detect, check for the variable first
if ($_SESSION['desktop'] != 1)
{
  // check for mobile and redirect
}

The problem you're facing is that you're being redirect back to your mobile domain again as soon as you're on your main domain with your mobile device. 您面临的问题是,使用移动设备进入主域后,您将立即再次重定向回您的移动域。

You could try something like the following: 您可以尝试以下操作:

If the user wants to access the normal version, set a session variable and redirect him to the normal domain. 如果用户要访问普通版本,请设置会话变量并将其重定向到普通域。 On the normal domain, only execute the phpmobilizer as long as the session var for only accessing the normal domain hasn't been set. 在普通域上,只要未设置仅用于访问普通域的会话变量,就仅执行phpmobilizer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM