I'm having an issue with the node alias when users are redirected to the mobile site. I have not upgraded to 7.x-3.x-dev yet, as the project page states to not use it on production sites.

I'm having an issue with the redirect when it comes to a node with multiple aliases. It seems that when the url is constructed after the redirect, it automatically uses the preferred alias for the node, even if the user typed in one of the other aliases. For ex:

node/### has 3 aliases

page/a (preferred)
page/b
page/c

If someone goes to www.mydomian.com/page/c, mobile tools automatically redirects them to the preferred alias, leaving them at m.mydomain.com/page/a. It still brings them to the correct node, but doesn't preserve the alias they originally typed. This is interfering with some of our URL tracking on webforms (which tell us which ad campaign people came from).

Once you've been redirected initially to the mobile url, the aliases work fine - I'm only experiencing it on the initial redirect where it goes from the desktop to mobile version.

Any ideas? Or can anyone replicate this? This is really holding us up on some of our efforts recently.

Comments

ekidman’s picture

Well, I seem to have found a fix for the issue. I'm not a PHP whiz, so if anyone reading this sees anything wrong, or knows of a better way to do it, feel free to chime in and let me know. But for people having similar issues, I had to update function mobile_tools_get_redirect_url() in mobile_tools.module:

At the end of that function, where the url is assembled:

//create the path and reassemble
  $base = preg_replace('{/$}', '', $destination_url);
  $url = url($base . '/' . $_GET['q'], array('query' => $query));
  return $url;

I used some code from http://drupal.org/node/1010820#comment-5920958 (which fixes an issue where the redirect was not using the alias at all) and updated it as such:

//create the path and reassemble
  $addr  = ltrim($_SERVER['REQUEST_URI'], '/');
  $base = preg_replace('{/$}', '', $destination_url);
  $currentUrl= url($addr, array('query' => $query));
$currentPath=str_replace(base_path(),"/",$currentUrl);
  $url =  $base . $currentPath ;
  return $url;

The $_SERVER['REQUEST_URI'] is what will actually grab the correct alias and bring it across. I added in the $addr variable to get rid of an extra leading slash (url's were appearing as mydomain.com//my/alias).

ekidman’s picture

Status: Active » Closed (fixed)