Hi dev team,

I realised that my Chinese Furniture site has a lot of duplicated content for translated pages.

I use 2 domains one for English and one for Chinese. I have no idea how Google could be too quick to index the site that the Chinese nodes was indexed as jyfurn.com/node/x where x is the node id. I was so confident that Global Redirect would do the job of redirecting the "/node/x" to the porper clean url, but after testing I realize it doesn't.

I beleive other people are facing the same problem for multilingual site too, just they haven't realized yet.

Attached is the Google index of my English site.

So please help us. Thanks very much.

Regards
Binh

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

woot’s picture

That right ! Just realized that google is indexing this pages :(

Would be nice if there is a up-comming patch for this issue.. anyway great module !

halfgaar’s picture

Category: feature » bug

I have it too, with a site in English and Dutch. English pages are available as http://domain/pagename. Dutch pages as http://domain/nl/pagename. If you go the node number of a Dutch page, you are not redirected properly.

I changed this to a bug report, because a feature makes it sound optional.

halfgaar’s picture

To be clear, going to node/x doesn't redirect, but going to nl/node/x does. It should do so in both cases.

halfgaar’s picture

We ended up deleting the global redirect module and fixed it by using 22 lines of PHP and one line of .htaccess. It's faster and more robust.

See: http://blog.bigsmoke.us/2009/06/10/enforcing-drupal-url-aliases

AdrianB’s picture

Subscribing

mani.atico’s picture

susbscribing

fhelmschrott’s picture

Status: Needs work » Active

really no solution for that essential problem yet? can't believe.

kepesv’s picture

Subscribe.. But the temporary solution:

Here is the "Domain name only" language selection version from halfgaar's solution (#4)

 
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
 
$result = db_query("SELECT * FROM {url_alias} WHERE src = 'node/%d' LIMIT 1", $_GET['nid']);
if ( db_error() ) die("O agony!");
 
$url_alias_object = db_fetch_object($result);
$destination = $url_alias_object->dst;
 
$result = db_query("SELECT domain FROM {languages} WHERE language = '%s'", $url_alias_object->language);
if ( db_error() ) die("O agony!");
 
$domain = db_result($result);

header("Location: $domain/$destination",TRUE,301);
 

(And of course You need the .htaccess modification from here:
http://blog.bigsmoke.us/2009/06/10/enforcing-drupal-url-aliases)

2xe’s picture

FileSize
1023 bytes

Suggestion for path prefix only... Attached patch is a regular diff against the current release version.

  • When using path prefixes the $language variable is always set to the sites default language
  • drupal_get_path_alias needs the $language_code to query the relevant section of the url alias table, since the $language variable is unreliable.
  • We must correct the $alias to include the path prefix.
2xe’s picture

FileSize
1002 bytes

fixed a bug.

2xe’s picture

FileSize
1.04 KB

Another bugfix; don't change prefix unless the language is enabled...

Edit:
For multilingual sites using path prefixes requests to any language but the default language did not get redirected to the aliased URL. I have been using this patch for a few days now, and it seems to work fine.

Boobaa’s picture

Subscribing.

okokokok’s picture

Issue tags: +i18n

This i18n issue has been bothering me for a long time now. Happy to see some work has been done already towards fixing this.

SeroSero, I had to reverse apply your patch:

patch -p0 -R globalredirect.module < patch_5_1.diff 

I only took a quick look but it doesn't seem to work as intended on the one site I tried it on.

okokokok’s picture

I'm having more luck with preg_match("@^node/(\d*)$@", $path, $regs) \d instead of /d and $path instead of $request.

I also added $options['language']->language = $language_code; to the if ($languages[$language_code]->enabled) condition.

Now something is working, except that node/7144 goes to the English version of the node, whereas it should go to the Arabic. It's probably because the $prefix is simply dropped. And I'm getting redirect loops for arabic/node/7144 and arabic/node/8003 (the English translation). To be continued...

okokokok’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
FileSize
1.13 KB

I tried refactoring out this part into a separate function. Now it's kinda working but it breaks other parts (issue with trailing slash, and infinite 301 loops for english/node/123).
I'm going to spend some time on refactoring code into functions to make this problem easier to tackle.

okokokok’s picture

Status: Active » Needs review
FileSize
2.35 KB

I fixed the issue with the trailing slash by separating the $redirect_slash case.
I also moved more into a helper function to clear things up a bit (at least in my head :)

This needs a review now.
But beware, I have surely overlooked things and this patch will definitely break your production site!

I'm going to try to tackle the redirect across domains now.

okokokok’s picture

One minor issue: arabic/node/8003 is an English language node but not redirected to the English language.

And here's the fix:

    if (preg_match("@^(.*/)?node/(\d*)$@", $path, $regs)) {
      $n = node_load($regs[2]);
okokokok’s picture

Ok, just finding out that this issue is _another_ duplicate of http://drupal.org/node/201675

okokokok’s picture

Status: Needs review » Closed (duplicate)

I'm marking this as a duplicate of #201675: Redirect to version in native language. Correct me if I'm wrong,