http://m.cvg.lochttp//cvg.loc/california

I know redirection must be working for other people, so tell me if you think there's something about my setup that's causing this.

With redirection on, and mobile / desktop URL as:

When I go to http://cvg.loc/mypath, I get redirect to this URL: http:m.cvg.lochttp://cvg.loc/mypath.

The problem appears to be in mobile_tools_get_redirect_url(), with these lines:

  $currentPath = str_replace(base_path(), "/" ,$currentUrl);
  $url =  $base . $currentPath ;

$currentURL is "http://cvg.loc/mypath"

base_path() returns "/", so the domain name isn't getting stripped out of $currentURL, and the mobile URL in $base is added.

When I change those lines to this, the problem disappears:

  global $base_url;
  $currentPath = str_replace($base_url, "" ,$currentUrl);
  $url =  $base . $currentPath ;

Comments

kentr’s picture

Issue summary: View changes

Updated description

kentr’s picture

Issue summary: View changes

Added formatting.

kentr’s picture

Title: Problem with mobile_tools_get_redirect_url() » Redirect fails with domain name language negotiation

I think the problem is with domain name language negotiation.

language.inc, language_url_rewrite() causes the URL returned by url() to be absolute:

      case LANGUAGE_NEGOTIATION_DOMAIN:
        if ($options['language']->domain) {
          // Ask for an absolute URL with our modified base_url.
          $options['absolute'] = TRUE;
          $options['base_url'] = $options['language']->domain;
        }
        break;

This brings up another issue that on other language subdomains the Mobile URL won't match anyway, so some sort of hook to change the redirect URL would be helpful.

kentr’s picture

Issue summary: View changes

Removed stupid assumption.

kentr’s picture

Issue summary: View changes
Status: Active » Closed (outdated)