Project:Global Redirect
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (duplicate)
Issue tags:i18n

Issue Summary

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

AttachmentSizeStatusTest resultOperations
In-redirected-URL.png13.52 KBIgnored: Check issue status.NoneNone

Comments

#1

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 !

#2

Category:feature request» bug report

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.

#3

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

#4

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

#5

Subscribing

#6

susbscribing

#7

Status:needs work» active

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

#8

Subscribe.. But the temporary solution:

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

<?php

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)

#9

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.
AttachmentSizeStatusTest resultOperations
patch.diff1023 bytesIgnored: Check issue status.NoneNone

#10

fixed a bug.

AttachmentSizeStatusTest resultOperations
patch.diff1002 bytesIgnored: Check issue status.NoneNone

#11

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.

AttachmentSizeStatusTest resultOperations
patch.diff1.04 KBIgnored: Check issue status.NoneNone

#12

Subscribing.

#13

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.

#14

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...

#15

Version:6.x-1.2» 6.x-1.x-dev

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.

AttachmentSizeStatusTest resultOperations
language-prefix.patch1.13 KBIgnored: Check issue status.NoneNone

#16

Status:active» needs review

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.

AttachmentSizeStatusTest resultOperations
language-prefix2.patch2.35 KBIgnored: Check issue status.NoneNone

#17

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

And here's the fix:

<?php
   
if (preg_match("@^(.*/)?node/(\d*)$@", $path, $regs)) {
     
$n = node_load($regs[2]);
?>

#18

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

#19

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,