On multilingual sites with language negotiation set to domain, url() always returns absolute URLs. So when your site runs on both http://example.com/ and http://example.nl/, url('flag') returns either http://example.com/flag or http://example.nl/flag. This causes the robots.txt recommendation to be wrong. It should suggest adding Disallow: /flag/, but now it recommends Disallow: http://example.com/flag/.
The following code replacement in flag.install fixes this:
Replace:
$flag_path = url('flag') . '/';
With:
$flag_path = url('flag') . '/';
// url() may return an absolute URL when language negotiation is set to domain
$flag_path = parse_url($flag_path, PHP_URL_PATH);
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | flag-language-negotiation-domain-1804228-1.patch | 606 bytes | Jorrit |
Comments
Comment #1
Jorrit commentedThe patch.
Comment #2
joachim commentedCan you not explicitly tell url() to not return an absolute URL?
Comment #3
Jorrit commentedThanks for your quick response. Unfortunately, the rewriting always happens in
locale.inc, functionlocale_language_url_rewrite_url().$options['absolute']is set toTRUEwhen language negotiation is set to domain.See http://drupalcode.org/project/drupal.git/blob/refs/heads/7.x:/includes/l... .
Comment #4
joachim commentedComment #5
joachim commented#1: flag-language-negotiation-domain-1804228-1.patch queued for re-testing.
Comment #6
joachim commentedThanks!
Committed, with a tweak to the comment wording and spacing.
git commit -m "Issue #1804228 by Jorrit: Fixed robots.txt recommendation wrong when language negotiation is domain based." --author="jorrit "
Comment #7
Jorrit commentedThanks for committing, I appreciate the commit attribution.