简体   繁体   English

禁用重定向脚本

[英]Disable redirection script

We have a redirect script on our site that detects mobile devices and redirects users to a subdomain which goes to the mobile site folder. 我们的站点上有一个重定向脚本,该脚本可检测移动设备并将用户重定向到子域,该子域将转到移动站点文件夹。 But now we need a mechanism that gives the visitor a button on the page that then reloads the page and bypasses this check. 但是现在我们需要一种机制,使访问者在页面上具有一个按钮,然后重新加载页面并绕过此检查。 The goal is if a smartphone user wants to see the full site, we need to give them a button to push to do so. 我们的目标是,如果智能手机用户希望查看整个网站,我们需要为他们提供一个按钮来推动它。 So, the question is: is it possible to disable this script when user clicks on that button? 因此,问题是:当用户单击该按钮时是否可以禁用此脚本?

I beleive cookies are a more better solution since they will not go away when the page is changed. 我相信cookie是一个更好的解决方案,因为更改页面后它们不会消失。

Just make a cookie when the user clicks the button and send him to the mainsite. 当用户单击按钮并将其发送到主站点时,只需制作一个cookie。

How to make the cookie:_ 如何制作Cookie:_

setcookie("fullsite", "SomeRandomThing", time()+60*60*24*30); // It will expire after a month

If the cookie is not set, then make it redirect. 如果未设置cookie,则使其重定向。

if (!isset($_COOKIE['fullsite'])
{
  // redirect
}

Similarily make a button for the user to switch back and make that button delete the cookie. 同样,为用户创建一个按钮以切换回该按钮,并删除Cookie。

yes you can. 是的你可以。 load script according to the button press. 按按钮加载脚本。

if((!isset($_POST['button']) && mobiledevice==true))
{
         //put your redirection script here
}

use something like above 使用上面的东西

What I have done in the past is have a button on all the mobile specific pages that sets a cookie and then redirects the user back to the non mobile page, that cookie is read and if set adds a "back to mobile" banner and skips the mobile redirection code. 我过去所做的是在所有特定于移动设备的页面上都有一个按钮,该按钮设置一个cookie,然后将用户重定向回非移动页面,读取该cookie,如果设置,将添加“ back to mobile”横幅并跳过移动重定向代码。

Also did a one time use version of this that does not show the "back to mobile" banner and automatically clears the cookie so the next page the suer visits they are back to mobile 也曾做过一次使用该版本的版本,该版本不显示“返回移动”横幅并自动清除cookie,以便下一页用户可以访问他们返回到移动

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

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