Hi,

Thank you for this module, it is really helpfull.

I have multilanguage site (with Internationalization). I tried to configure redirect for node languages between domains but it is not working.

I have two domains:

  • www.example.com
  • www.example.ru

I have node http://www.example.ru/node/1 in Russian language. When I try to access this node on other domain (http://www.example.com/node/1) I hoped that page will be redirected to http:///www.example.ru/node/1. Insted of that I was redirected to http://www.example.com/www.example.ru/node/1. Of course, I got 404 error (page not found).

I found this bug and fixed it. Patch that solves this problem is attached.

Thanks for your time.

Best,
Spleshka.

Comments

spleshka’s picture

Issue summary: View changes

Fixed urls filter.

spleshka’s picture

I found one more bug there.

If the page URL has an alias, then the browser records the infinite redirect. This bug occurs because you compare URL alias with real URL. See patch for more info (attached).

spleshka’s picture

Sorry, the second bug was because of "Set Content Location Header" setting. But the first patch is still necessary for the correct redirect.

pvasili’s picture

Thanks for the patch

matglas86’s picture

Status: Needs review » Needs work

The

+++ b/globalredirect.moduleundefined
@@ -175,7 +175,9 @@ function globalredirect_init() {
+                  drupal_goto('http://' . $lang->domain . '/' . $alias, $options, 301);

The http:// is to much. Because external is set it already creates a http in front of it. My redirect does not work because of that.

heivoll’s picture

The first patch works fine for me. The second, however, introduces redirect loops on all my nodes.

@matglas86: No, the http:// is what's necessary here, and is what the fix consists of. Unless you actually have the http:// set in your language domain settings of course, then you'll get a problem. However, this is not recommended as it would then lock that language to only one protocol (and potentially create other problems I can't think of right now).

The question of protocol here (http vs. https) is relevant though. It shouldn't really be set to http:// statically, but rather be set to the current protocol.

spleshka’s picture

Status: Needs work » Needs review
StatusFileSize
new809 bytes

Agree with @heivoll. Attached new patch.

heivoll’s picture

I can confirm that the patch in #6 works fine for me!

heivoll’s picture

Double post, sorry.

rreynolds4’s picture

I found this at just the right time. Patch #6 seems to be doing the trick for me as well.

matglas86’s picture

StatusFileSize
new756 bytes

I found little short route while digging a little deeper. Drupal can handle the correct link building itself when providing the language object to the drupal_goto function.

matglas86’s picture

Issue summary: View changes

Fixed bug in html code.

caschbre’s picture

Just wanted to double check on the patches here... I noticed in patch #6 that it is taking into consideration the protocol (http/https). I'm assuming that the patch only applies this logic for translation-based URLs?

Reason I'm asking is I'm running into issues where globalredirect is switching the protocol on me (http://example.com/?q=some-string --> https://example.com/some-string).

The fix in #6 looks close to what I want but the logic block it is in seems to only pertain when the translation module is enabled. If that's the case then I plan to extract that logic out of that logic block so it applies elsewhere.

Carl Johan’s picture

Issue summary: View changes
StatusFileSize
new592 bytes

#10 didn't apply cleanly for me, so just re-rolling.

chris matthews’s picture

The 5 year old re-rolled patch in #12 to globalredirect.module still applies cleanly to the latest 7.x-1.x-dev.