Migrating a HTML-based, multilingual site with 2000+ heavily interlinked pages to drupal I ran in this issue. To reproduce:
In the body of a page put a link with href="/node/xxx", where the node xxx is in a language that should have a language prefix "de". Clicking the link opens http://domain.tld/node/xxx instead of http://domain.tld/de/node/xxx.
Turning on path prefix negotiation should either make drupal render HTML, where all links are rewritten with proper language path prefix and/or redirect all urls without prefix to the proper prefixed urls.
Not doing so results in issues like broken navigation in multilingual sites (when using primary links as a multilingual variable in settings.php) and duplicate content (because the exact same node is not only reachable both with and without path prefix, but is likely to be referenced inside the site with both urls.)
Trying to work around this issue with url aliases doesn't work, because then urls with path prefixes will be redirected to http://domain.tld/de/de/node/xxx, which is no valid url. Rewriting links in the theme or updating the nodes via sql in the database are ugly workarounds, that probably will work. I'd rather see the root cause fixed instead.
Any ideas?
Comments
Comment #1
gábor hojtsyYou should use a link token module that lets you use markup which is replaced in the filtering system when the node is rendered. If you hard-wire links in your node, Drupal will not change those for you in any case. This could be a feature request for Drupal 8, but still it would need to change your links when your URL aliases change (which could happen in bulk if you use pathauto) and in other cases. There are just too many options, and Drupal does not do any node rewriting in any case at all. All Drupal does is it transforms your node for display with filters when viewed.
I'm repurposing this as a feature request to add such a filter complemeting what Drupal already does. Still for that you'll need to write your HTML with special markers like [site-link] or something, depends on how people want to implement this.
Comment #2
joergvk commentedThanks for the tipp and the background info. Unfortunately, I can't find a filter module, that can use node tokens at run-time of filter execution. (Is there any?) But I guess, I can achieve that in our custom theme. We are already doing a lot of rewriting there and we could quite easily add link-rewriting there. To have it in Drupal core would be great, though!
Comment #3
dave reidThis is a duplicate of #401956: Provide an [internal] filter