Hi!
Just installed gobalredirect on a 6.x bilingual site (IT default and EN).
Enabled the canonical URL feature and noticed that for the English content the prefix was duplicated:
http://mysite.com/en/en/mycontent
Since I am on IIS6, rewriting URLs with IIRF, I thought that was the problem, but I was able to reproduce the "bug" also on my local install (basic WAMP stack, W7).
Noticing that the canonical URL is produced by this code in the module:
// Add the canonical link to the head of the document if desired.
if ($settings['canonical']) {
drupal_add_link(array(
'rel' => 'canonical',
'href' => url(drupal_is_front_page() ? '<front>' : $_REQUEST['q'], array('absolute' => TRUE, 'query' => $query_string)),
));
}
I have replaced $_REQUEST['q']
with $_GET['q']
and now canonical URL are output correctly.
I have tested quite thoroughly this and it seems to work fine, but I am not 100% sure about what I have done :P
Am I going the right path with this mod? Is there any caveat I should be aware of?
Thanks!
Comment | File | Size | Author |
---|---|---|---|
#9 | globalredirect-double-language-prefix-canonical-url-1122720-9.patch | 556 bytes | esclapes |
Comments
Comment #1
nunof CreditAttribution: nunof commentedI'm getting this issue too in D7.
I have two languages enabled, with prefixes. All my canonical links are broken.
E.g.:
/en/en/contact
Also, D7 already includes canonical links for nodes, so on node pages I get two canonical links: one, correct, from Drupal and another from Global Redirect but with the double prefix for the language.
Comment #2
FiNeX CreditAttribution: FiNeX commentedbug confirmed in Drupal 7
Comment #3
akaserer CreditAttribution: akaserer commentedsubscribing
Comment #4
chicodasilva CreditAttribution: chicodasilva commentedsubscribing
Comment #5
knalstaaf CreditAttribution: knalstaaf commentedI'm getting even this in D7.9:
domain.com/en//en//admin/content (page not found)
Is there a solution out there?
Comment #6
richH CreditAttribution: richH commentedHi,
I have this problem and just tried the fix at the top of the post. So far so good...... (fingers crossed)
Rich
Comment #7
boreg CreditAttribution: boreg commentedAlso getting this in global redirect dev (2011-Dec-29) with D7.10 and i18n 7.x-1.2
Comment #8
FiNeX CreditAttribution: FiNeX commentedThe bug is still reproducible using a classic LAMP stack. The fix suggested on the first post works fine.
Comment #9
esclapes CreditAttribution: esclapes commentedPatch against 6.x-1.x attached. Fix is quite simple (thanks bohz)
Moving to major, as this bug was causing Google Crawler to follow thousands of non-existent URLs on our site.
I am not marking my own patch as RTBC, however it seems to work per the comments above.
Comment #10
ShaneOnABike CreditAttribution: ShaneOnABike commentedI had the same issue actually which is frustrating. I'll let you know after the next crawl session whether this works properly (nice catch btw)