[support] how to handle internal links
Ray Zimmerman
rz10 at cornell.edu
Tue Jul 4 21:14:49 UTC 2006
On Jul 4, 2006, at 3:40 PM, Jason Flatt wrote:
> Try it w/o the leading slash. If your $base_url is setup correctly
> (and 4.7 is
> supposed to handle that for you), it should work with either path.
> If that
> still doesn't work, try setting and uncommenting the $base_url
> variable in
> your sites/default/settings.php file.
That doesn't work either. I do have $base_url set correctly, and I
assume that is why, for example, menus that point to "node/99" work
fine when moved to a site with a different $base_url. However, I
don't think links in content are affected in any way by $base_url. In
fact, they can't be unless Drupal is doing filtering of <a
href="..."> tags by default (which would be a surprise to me).
Suppose I have content in, say, node 10 that contains the following
link <a href="node/99">link</a>. These are simple relative URLs that
are turned into absolute URLs by the browser, resulting in the
following:
Dev site:
$base_url = "http://example.com/dev";
node 10 at: http://example.com/dev/node/10
link points to: http://example.com/dev/node/node/99
Production site:
$base_url = "http://example.com/";
node 10 at: http://example.com/node/10
link points to: http://example.com/node/node/99
In both cases, the link is obviously broken.
To be fair, it appears that these relative URLs *did* work in Drupal
4.6, because it (ab)used a base tag that was added to every page
pointing to the root URL of your site. Since this (ab)use of base was
fixed in 4.7, relative URLs no longer work. [1]
I'm coming to the conclusion that it requires an input filter to
convert relative internal links into absolute URLs by using $base_url.
Any other possibilities?
Ray
[1] According to http://drupaltutorials.com/
drupal_theme_development#differences_between_drupal_4.6_and_4.7
More information about the support
mailing list