Needs review
Project:
Global Redirect
Version:
6.x-1.2
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Jul 2011 at 21:31 UTC
Updated:
3 Nov 2011 at 18:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mac_weber commentedI just realize it happens only if at Global Redirect's config is not set the option "Language Path Checking".
However, it is interesting in some cases not redirect and have the canonical pointing to the original content. For example, in case the admin wants to keep the interface language yet the content is displayed on a different language.
Comment #2
mrfelton commentedThis is a problem in Drupal 6 too, and it stems from the fact the url() function is being used to generate the canonical url. I have spent some time working through this issue, and come up with this patch which does the following:
1) If a node is language neutral, then the Canonical URL will point to the unprefixed version of the node, regardless of how you access the page. For example
node/1 has url alias my/page
visiting /my/page => canonical url = http://www.example.com/my/page
visiting /en/my/page => canonical url = http://www.example.com/my/page
visiting /es/my/page => canonical url = http://www.example.com/my/page
2) If a node is language specific, then the Canonical URL will point to the correct version of the node. For example
node/1 has url alias my/page and language en
visiting /en/my/page => canonical url = http://www.example.com/en/my/page
visiting /es/my/page => 404 error, nothing to do here
3) If a node is langage specific, and has translations in other languages then the Canonical URL will point to the correct version of the node. For example
node/1 has url alias my/page and language en
node/2 has url alias my/page and language es
visiting my/page => canonical url = http://www.example.com/my/page
visiting es/my/page => canonical url = http://www.example.com/es/my/page
This has only been tested with LANGUAGE_NEGOTIATION_PATH_DEFAULT, and is for Drupal 6. This also corrects the problem described in #1205982: multi-language globalredirect with pathauto creates bad canonical.
Comment #3
mac_weber commentedmrfelton, thanks for the patch. I will test it and post a feedback.
Comment #4
mac_weber commentedI just added the comment number to the file name, so it can pass by QA
Comment #5
jthorson commentedJust testing ... but I think the patch is against 6.x.
Comment #6
jthorson commentedComment #7
jthorson commentedComment #8
jthorson commentedComment #9
chicodasilva commentedHas anyone tested patch #6 for drupal 7?
Comment #10
anouHello,
I've tested patch #6 on Drupal 7. You have to add
$query_stringas argument of the new function:_globalredirect_get_canonical($path, $query_string) {...But the function removes the language prefix...
So I just changed the canonical part :
and this way I don't have duplicate prefixes. I have a patch but I not sure that's the right place to attach it.