Skip to main content
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Tweeted twitter.com/#!/StackDrupal/status/407454629933633536
Source Link
Meggy
  • 427
  • 2
  • 15

Mobile_detect php redirecting to subdomain - Stuck in a redirect loop!

I am using the following code in a module for redirection to a subdomain whenever a mobile is detected;

<?php

  function mobydetect_init() {
  include("PATH/TO/Mobile_Detect.php");

  $detect = new Mobile_Detect();
  if ($detect->isMobile()) {
    header('Location: http://m.mysite.com');
    drupal_exit();
  }
}

However when I go to my site using a mobile I get this error message;

"This web page has a redirect loop."

I have disabled to subdomain from redirecting to the main domain in Aegir. So where's the loop coming from?