Hello all,

I have a site that's desktop URL is http://www.example.org/2011/ and I would like the mobile URL to be http://www.example.com/2011/mobile.

But when I set MT to those settings and enable "Enable automatic redirection of the mobile user". The mobile browser begins to loop and eventually loads an error stating that there was too many redirects. Once I OK that error the URL is http://www.example.com/2011/mobile/mobile/mobile/mobile/mobile/mobile/mo... - or something close to that.

That node/17912 happens to be the /mobile node- but it doesn't load correct (As the URL is so wrong).

Any ideas as to what would be causing this?

Thanks!

CommentFileSizeAuthor
#2 mobile_tools-redirects-1220166-3.patch577 bytesVanD
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

VanD’s picture

Having similar problems. Subscribing.

EDIT: My problem is also with mobile redirect enabled. If the sure goes to a path that is not the homepage I get too many redirects.

http://example.com/ redirects to http://m.example.com (Works on mobile device)
http://m.example.com redirects to http://example.com (Works on non mobile device)
htt://example.com/node/181 does not work, gives too many redirects (on mobile device)

VanD’s picture

I've fixed the problem on my site, and created a patch for 6.x-2.3 - The patch would also work for the dev version if the line numbers are updated.

Basically, the formatting of the destination URL wasn't working properly for my use, it's now down in a very simple fashion, and seems to work well. Let me know if I over looked something.

Cheers.

VanD’s picture

Status: Active » Needs review
minorOffense’s picture

Status: Needs review » Needs work

I'm a little confused as to what we're fixing. The function below is what is in the latest 6.x-2.x

/**
 * Creation of the redirect url. Special care to create the correct url that will
 * cause the Global Redirect module not to redirect!
 */
function mobile_tools_get_redirect_url($destination_site) {
  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  $destination_url = ($destination_site == 'mobile') ? variable_get('mobile_tools_mobile_url', '') :  $destination =  variable_get('mobile_tools_desktop_url', '');
  // collect query parameters
  if (drupal_is_front_page()) {
    return $destination_url;
  }
  $query = array();
  foreach ($_GET as $key => $value) {
    if ($key != 'q') {
      $query[] =  $key . '=' . $value;
    }
  }
  $query = (count($query) > 0) ? implode('&', $query) : '';
  //create the path and reassemble
  $base = preg_replace('{/$}', '', $destination_url);
  $currentUrl = url($_GET['q'], array('query' => $query));
  $currentPath = str_replace(base_path(), "/" ,$currentUrl); 
  $url =  $base . $currentPath ;
  return $url;
}

Which as you report states can cause the end of the URL to stack (ex: /mobile/mobile/mobile....)

Not sure how the patch above fixes that issue?

VanD’s picture

This issue is almost a year old, and I am no longer using it. Sorry.

benschaaf’s picture

I can't speak to the patch, as VanD said, its been awhile since I thought about this one.

But, our issue ended up being server related. So, we resolved it there and didn't try to patch.

minorOffense’s picture

Assigned: Unassigned » minorOffense
Status: Needs work » Needs review

I'll review and see if the patch is still required.

ain’s picture

Priority: Normal » Critical

I've reproduced the issue also on 6.x-2.7. Still goes to infinite redirect, tested in iPad and iPhone running latest iOS/Safari.

Upgrading to Critical.

NOTE: strangely enough, works on iPad, but not on iPhone.

ain’s picture

Above code does not resolve, applying the patch makes no difference.

ain’s picture

Priority: Critical » Normal

According to http://drupal.org/node/1298270#comment-5245848, the $cookie_domain has to be enabled with the domain in the settings.php. This resolved the problem for me.

It seems many people are having this issue, it's definitely necessary to document it or implement a helper function in the module that alerts the necessity for the setting.

Downgrading back to normal.

ain’s picture

Issue summary: View changes

fixed typo