Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#33 | globalredirect-language-domain-1514166-33.patch | 592 bytes | mrinalini9 |
| |||
#32 | globalredirect-language-domain.patch | 694 bytes | miiimooo |
#26 | globalredirect_language_domain_1514166-26.patch | 1.97 KB | Koen.Pasman |
#19 | globalredirect_language_domain_1514166-19.patch | 1.97 KB | Koen.Pasman |
| |||
#15 | globalredirect_language_domain_1514166-15.patch | 1.93 KB | Koen.Pasman |
Comments
Comment #1
Sergii CreditAttribution: Sergii commentedSince redirect goes to another domain let url function determines whether the redirect is external.
Comment #2
paulrooney CreditAttribution: paulrooney commentedTested, and works as intended. Thanks!
Comment #3
Anders Kallin CreditAttribution: Anders Kallin commentedHi,
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.
Comment #4
michaelpetri CreditAttribution: michaelpetri commentedI had the same problem, patch dosn't work for me.
This works for me:
Comment #5
gioppy CreditAttribution: gioppy commentedHi,
I had the same problem and I think the problem is the missing protocoll in the drupal_goto() url.
This works for me:
Comment #6
yehudade CreditAttribution: yehudade commentedVersion: 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.
Comment #7
yehudade CreditAttribution: yehudade commentedI 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)
Comment #9
apanag CreditAttribution: apanag commentedThe following code worked for me:
Comment #10
k4v CreditAttribution: k4v commentedHere's another solution.
Comment #11
k4v CreditAttribution: k4v commentedoops
Comment #12
k4v CreditAttribution: k4v commentedComment #13
k4v CreditAttribution: k4v commentedcorrected whitespace
Comment #14
aleksijohansson CreditAttribution: aleksijohansson commentedSeems to be working fine with the newest release 1.5.
Comment #15
Koen.Pasman CreditAttribution: Koen.Pasman commentedI 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.
Comment #19
Koen.Pasman CreditAttribution: Koen.Pasman commentedAlso, 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.
Comment #20
Koen.Pasman CreditAttribution: Koen.Pasman commentedComment #24
jasom CreditAttribution: jasom commentedWhy does the #19 patch failed testing? It worked for me.
Comment #25
beumont CreditAttribution: beumont commentedApplied patch #19 and works for me too! Will test this this week and post any errors
Comment #26
Koen.Pasman CreditAttribution: Koen.Pasman at Aubergine IT commentedRerolling patch to see if new tests will succeed, minor change in using globalredirect_goto() instead of drupal_goto()
Comment #27
sumachaa CreditAttribution: sumachaa commentedIs this same as https://www.drupal.org/project/globalredirect/issues/1653194
Comment #29
theRuslanpatch #19 works for me, thanks a lot!
Comment #30
defra_touch CreditAttribution: defra_touch as a volunteer commentedPatch #19 works for me too, thank you very much!
Comment #31
parisekCreated simple module that solve this issue for me https://github.com/parisek/custom_i18n_redirect (I prefer that instead of patching module)
Comment #32
miiimoooThis 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)
Comment #33
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedRerolled patch for #32 as it failed to apply, please review.