With enabled 'Language Path Checking' option Globalredirect module redirects to the right path of the node according to its language.
But when language negotiation is set to 'domain' (hence the node is located on different domain) Globalredirect still assumes that the redirect is internal.
Therefore, it escapes url string and makes internal redirect, f.i. http://en.domain.com/http%3A//ru.domain.com/russian_node.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sergii’s picture

Status: Active » Needs review
FileSize
663 bytes

Since redirect goes to another domain let url function determines whether the redirect is external.

paulrooney’s picture

Tested, and works as intended. Thanks!

Anders Kallin’s picture

Hi,

I'm not sure if I've configured my site in some weird manner, but I don't get this to work with this patch.

The URL protocol is not a part of $lang->domain.

I'm running on two private IP addresses but that could hardly have any impact, right?

http://192.168.0.131/node/1 (English node on Swedish site) redirects to http://192.168.0.131/192.168.0.130/wedding-logos instead of http://192.168.0.130/wedding-logos.

michaelpetri’s picture

I had the same problem, patch dosn't work for me.

This works for me:

              // There is a matching language for this alias
              if ($alias != $current_path) {
                if (isset($lang->domain)) {
                  $options['language'] = $lang;
                  drupal_goto($alias, $options, 301);
                }
                break;
              }
gioppy’s picture

Hi,
I had the same problem and I think the problem is the missing protocoll in the drupal_goto() url.
This works for me:

// There is a matching language for this alias
if ($alias != $current_path) {
  if (isset($lang->domain)) {
    global $is_https;
    $options['external'] = TRUE;
    $options['absolute'] = TRUE;
    $protocoll = $is_https ? 'https://' : 'http://';
    drupal_goto($protocoll . $lang->domain . '/' . $alias, $options, 301);
  }
  break;
}
yehudade’s picture

Issue summary: View changes

Version: 7.x-1.5

I also have an issue with the LOCALE_LANGUAGE_NEGOTIATION_URL_DOMAIN case, but the issue is that there is no redirect.
The node has no special path, just node/2.
if node/2 is on english, he.domain.tld/node/2 does not get redirected to en.domain.tld/node/2 since the paths are both the same.
I tried fixing it but I did not get the loop's behavior and only caused a redirect loop.

yehudade’s picture

I went back to fix this issue, so here is my solution:
Instead of the current loop it checks for the actual node's language, Then if the current domain and the node language's domain are different it redirects to the correct domain.
(the use of the alias is just a bonus, to reduce redirects, e.g. lang1.domain.tld/node/2 > lang2.domain.tld/node/2 > lang2.domain.tld/somepage)

Status: Needs review » Needs work

The last submitted patch, 7: globalredirect_language_domain_1514166-2.patch, failed testing.

apanag’s picture

The following code worked for me:

global $is_https;
$scheme = $is_https ? 'https://' : 'http://';
$options['external'] = TRUE;
drupal_goto($scheme . $lang->domain . '/' . $alias, $options, 301);
k4v’s picture

Here's another solution.

k4v’s picture

oops

k4v’s picture

Status: Needs work » Needs review
k4v’s picture

corrected whitespace

aleksijohansson’s picture

Version: 7.x-1.4 » 7.x-1.5
Status: Needs review » Reviewed & tested by the community

Seems to be working fine with the newest release 1.5.

Koen.Pasman’s picture

I would like to reopen this issue because I suspect that the patch is not complete yet.

I'm running this patch together with a patched version of the redirect module (patched with https://www.drupal.org/node/1796596#comment-9313853 ) and when I'm trying to access a non-existing page, this patch creates an infinite redirect loop because $node is NULL here.

I've added this to the if-statement in my attached patch to prevent these redirect loops.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: globalredirect_language_domain_1514166-15.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 15: globalredirect_language_domain_1514166-15.patch, failed testing.

Koen.Pasman’s picture

Also, I am currently running into problems where I have nodes that are not translatable (and actually also not viewable on their own). Viewing the node causes to create an infinite loop. I adjusted my patch to check for the LANGUAGE_NONE case, in which I think we should not redirect at all.

Koen.Pasman’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: globalredirect_language_domain_1514166-19.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: globalredirect_language_domain_1514166-19.patch, failed testing.

jasom’s picture

Why does the #19 patch failed testing? It worked for me.

beumont’s picture

Applied patch #19 and works for me too! Will test this this week and post any errors

Koen.Pasman’s picture

Status: Needs work » Needs review
FileSize
1.97 KB

Rerolling patch to see if new tests will succeed, minor change in using globalredirect_goto() instead of drupal_goto()

sumachaa’s picture

Status: Needs review » Needs work

The last submitted patch, 26: globalredirect_language_domain_1514166-26.patch, failed testing. View results

theRuslan’s picture

patch #19 works for me, thanks a lot!

defra_touch’s picture

Patch #19 works for me too, thank you very much!

parisek’s picture

Created simple module that solve this issue for me https://github.com/parisek/custom_i18n_redirect (I prefer that instead of patching module)

miiimooo’s picture

Status: Needs work » Needs review
FileSize
694 bytes

This patch is based on the comment from @michaelpetri in #4

This fixes the problem when you have separate domains for languages - e.g. `mysite.se, mysite.com`

Going to http://mysite.se/node/123 where node/123 is in English will redirect to the correct alias on http://mysite.com/myalias

This works for me on a site with i18n, i18n_node, pathauto_i18n enabled (but not i18n_redirect)

mrinalini9’s picture

Rerolled patch for #32 as it failed to apply, please review.