Error:
---------
With a Drupal install on www.example.com/drupal
using <a href="somelink">somelink</a> in a page or a user created block,
where for example "somelink" = "node/2", Drupal renders an incorrect URL www.example.com/drupal/node/somelink,
where it should have been www.example.com/drupal/somelink; on normal pages, as in the example drupal renders www.example.com/drupal/node/node/2. Note the node/node/2. Clearly a node to many.
A "page not found" error results
----------
When does this happen:
----------
I have spent quite some time figuring this out. Here are my results
- Clean URL's enabled (not tested without)
- Path Module NOT ENABLED:
In this case, the error occurs on any node or page except the front page;
When images are asked for from the site, e.g. foo.jpg, using the <img src="somelink/foo.jpg"> tag, the images are not rendered by the system. In this case, the log entries for Top 'page not found' errors state that "node/somelink/foo.jpg is not found (by Drupal / the server).
- Path Module ENABLED
In this case, whenever pages have given a human-readable URL via de URL Path settings, only on these pages the error does not occur!
Even when Path module is switched off later, the error stays away. The error persists, however, on normal pages that are only known as node/123 etc.
---------------------
Workaround for single user installs (requires PHP allowed on relevant posts)
---------------------
Building upon http://drupal.org/node/102667, I found this line of PHP works for a reference with image source
<?php echo '<a href="'.base_path().'somelink"><img src="'.base_path().'system/files/foo.jpg" alt="foo" />'; ?>
This poses a security risk when you have more than one user on a true community site!
---------------------
System
---------------------
Drupal 5-10 out of the box
Server 1: Debian (Etch) Apache/2.2.3 (Debian) PHP/5.2.6-0.dotdeb.1 with Suhosin-Patch MySQL 5.0.32
Server 2: Linux, Apache PHP/5.2.0-8+etch10 MySQL 5.0.32
Theme Garland, Bluebreeze, Ad-the-morning-after - doesn't matter
----
Reproduce this bug
----
* Install Drupal 5-10 from out of the box
* Create a first page node/1, put in reference to node/1; upload image foo.jpg and put in reference to image
* Create a second page node/2, put in reference to node/2
* Make sure both pages are promoted to front page
* Test the links and observer the rendering of the url and the image fail whenever not on front page
* Activate Path module, and give node/2 the URL "test"
* Include a reference to test on node/2 or node/1. Include a link that must render image foo.jpg
* Observe that now the correct URL's are created on node/2, test, and the image is rendered, but still not on node/1, if not on front page
---------------------
Why does this deserve attention?
---------------------
Drupal has a lively community; having started from 4.4.2, Drupal has seen many upgrades, and notably the move to 4.7 and 5 was major.
Being pragmatic, with Drupal 6 released and 7 on the way (?), I believe Drupa 5 is considered stable, suitable for "production".
Thus I believe this annoying bug should be fixed in Drupal core / the package that comes out of the box.
---------------------
Comments
Comment #1
gpj commentedForgot to mention that of course the quick fix is to put in complete urls, like
http://www.example.com/drupal/somelink; however, when you work with a live site visible on the web and a development site on your local server, it becomes quite tedious if not impossible to adhere to a workprocess where you extend, modify and test your local site, then upload it.Any suggestions or other fixes welcome of course!
I have been looking into implementing a Rewrite rule, but have not yet figured out the syntax.
Maybe someone can develop a Rewrite rule for .htaccess where /node/node is replaced by /node, or where node/ is removed whenever it is not followed by a number (preferred, to also capture the remote chance that an node is inserted for a page where path url is set).
Comment #2
damien tournoud commentedThis is not a bug.
In its standard configuration, Drupal does not touch the URL found in the content you create, and does not use a "base" URL since the 5.x series, because it caused more trouble than it solved.
To ease the creation of "internal" URLs in content, please see the Path Filter module. After installing and configuring the filter on your input type, you will be able to enter
And Drupal will generate the correct URL for you.
Comment #3
gpj commentedThanks for the fast response. Works perfectly.
Took me over an hour again to figure it out, though.
1. there is no configuration of this module on the configuration by module page.
Instead, configure the filter via Site Configuration --> Input Formats --> Filtered HTML configure.
A rather obscure, non-intuitive place
2. the README.txt states "WARNING #2: Path Filter must run before Drupal's HTML filter so make sure to
set the weight accordingly!". Again, where to do this? Well, on the same menu, but on the REARRANGE tab. Awesome, huh!
Finally, having gone through this exercise, suggest that
Aye) Path Filter Module should be part of standard distribution package
The bug is fixed by installing and correctly configuring Path Filter Module
Bee) to give priority to the completion of the intelligible manuals series already on this site;
I believe this should have priority over going from 7.x to 8.x. If you can't explain it, some won't use it!
Comment #4
damien tournoud commentedThere is no such thing as a "standard distribution package". There is Drupal Core, which is the basic foundation block of everything, and there are (not so many) Drupal Distributions (for more information, see http://groups.drupal.org/distributions), targeting at some specific needs. Taking into account every specific needs is not really the job of Drupal Core, but thanks for your advice.
Comment #5
SanDiego commented@gpj Great.. Thanks for the step by step directions. Saved me some time..
Comment #6
mseraphim commentedHi There,
I know this is an old post, but hopefully someone can help me.
My site is doing exactly the same thing. When creating a new node and I open it I want to be able to navigate to other links as well, but it adds /node into all my links. example: http://localhost/home would be the url it is meant to go to, but it points to http://localhost/node/home.
When I disable clean url's, it workes fine, but I need to have clean url's on the site. So when I enable it again, the same problem just reoccurs.
Could anyone please help me with this, or should I post a new support request?
Regards,
Mseraphim
Comment #7
bfroehle commentedInstead of unburying the dead, please post a new support request.