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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nunof’s picture

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

FiNeX’s picture

bug confirmed in Drupal 7

akaserer’s picture

subscribing

chicodasilva’s picture

subscribing

knalstaaf’s picture

I'm getting even this in D7.9:

domain.com/en//en//admin/content (page not found)

Is there a solution out there?

richH’s picture

Hi,

I have this problem and just tried the fix at the top of the post. So far so good...... (fingers crossed)

Rich

boreg’s picture

Also getting this in global redirect dev (2011-Dec-29) with D7.10 and i18n 7.x-1.2

FiNeX’s picture

Category: support » bug

The bug is still reproducible using a classic LAMP stack. The fix suggested on the first post works fine.

esclapes’s picture

Priority: Normal » Major
Status: Active » Needs review
FileSize
556 bytes

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

ShaneOnABike’s picture

I 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)