1

I am using X-AH-Mobile-Redirect in the settings.php file to redirect visitors to the mobile site. I need to add a link so that visitors can switch to the desktop site.

Here is a snippet of the redirect code:

    if (isset($_ENV['AH_SITE_ENVIRONMENT'])) {
  switch ($_ENV['AH_SITE_ENVIRONMENT']) {
case 'dev':
   header('X-AH-Mobile-Redirect: http://m.mysite.com');
  break;
  }
};
0

I don't know about X-AH-Mobile-Redirect, but I did this a while ago by creating a link like http://example.com/?device=desktop and on page load I would check for $_GET['device'] and for a cookie

Then I could just check

if (isset($_GET['device']) && $_GET['device'] == 'desktop') {
    setcookie('mycookie', 'true', strtotime('+365 days'));
    $mobile_browser = 0; //This forces site into desktop mode
}

Then on desktop version you just go the other way around with a http://example.com/?device=mobile

if (isset($_GET['device']) && $_GET['device'] == 'mobile') {
    setcookie('mycookie', null, -1); //Unset cookie
}

Of course you have to add whatever you need to force your mobile detector to go into mobile/desktop version, but it's pretty much it, on page loads check for the cookie and for the query strings and act accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.