Hi guys,
I'm not sure if this warrants an issue or not..I'll jump back later to see if it's something I've done wrong or overlooked, or if it is a bug, but, I'm getting a strange problem with links with Drupal version 4.7.3 i.e. they don't work like they used to...
The simplest way of explaining it is if I'm on an admin page, the links in manually created blocks are appended with www.example.com/admin/link as opposed to what it should be i.e. www.example.com/link
Ditto for when I'm looking at a node...links look like this www.example.com/node/link instead of this www.example.com/link.
It's as if the base_url isn't being picked up properly...I've never had the problem before with previous versions on the same server, so I assume it's a new thing.
It only seems to affect manually created links and I worked around it by manually inserting the base_href in the page.tpl.php file. i.e.
<base href="http://www.example.com/drupal/" />
Thought I'd post this forum topic in case it rings any bells with others. I'll jump back later and see if it's a bug or it was something I have done wrong/overlooked.
Dub
Comments
Prefix with base path
The clean URLs that Drupal uses look like real directories to the browser. You must prefix relative links with the base path to avoid this (if your site is installed in the root, prefix with '/').
The <base> tag was removed in 4.7 because many crawlers did not respect it and got stuck in loops.
--
If you have a problem, please search before posting a question.
I too am having big problems with relative paths
I'm having big problems with relative paths. I have used quite a lot of links from page to page and, when I set up the site, I used links with the following format: "/node/xxx". I noticed that the menu item created for each page uses the format "node/xxx" - i.e. no leading forward slash. As the links for the menu item are generated by drupal I assumed that this format must be correct so set about changing the format in the links on my pages.
Oh dear!!! It should be a simple if tedious task, but I have discovered some very strange inconsistencies.
1. On some pages removing the leading forward slash has worked just fine. The link still works.
2. On some pages, removing the leading forward slash results in linking to the front page (/node) A glance at the status bar in my browser shows that the URL is being translated as http://domain.com/node/node/xxx i.e. /node is being put in twice!!!! on these pages, removing node/ so that the url is simply xxx (the node id) works, but doing the same thing in pages in group 1 does not work.
3. On pages with an alternative URL such as sections/baltic removing the leading forward slash results in a 'page not found' message. The status bar this time shows http://domain.com/sections/node/xxx i.e it has inserted part of the path from the alternative URL.
Can anyone throw any light on what is happening here?
same issue here
Everything was working fine in my windows/xampp sandbox. Since moving to a proper linux server, relative paths break but only when viewing the full node. Teaser views are fine. This occurs when themeing my cck types, both by tpl files and using contemplate. Clean URLs are required for imagecache.
I use the same code in my template for both teaser and full node. Links from teaser coded as:
Show up correctly, like this:
http://mydomain.com/subdir/node/73But if I put that in the full node section of my template, then all the links come out with an extra 'node' attached to them. Like this:
http://mydomain.com/subdir/node/node/73My sandbox had apache 2.2 and php 5, by server has apache 2.0 and php 4.
Drupal was orginially installed in apache's document root and has now been moved to a folder.
I have two other seperate Drupal installs on the same server without issue, neither are using custom templates
I've tried with
$base_url = 'http://mydomain.com/mydir', both on and off.I've tried with both
RewriteBase /mydirandRewriteBase /mydir/in my .htaccessI've tried with a leading forward slash, like
<a href="/node/<?php print $nid ?>">, but that gives mehttp://mydomain.com/node/73I'm totally stumpted.
Solution!
After a crash course in templating, I've found that my problems stemmed from what Steven was describing above. It's in the handbook here: http://drupal.org/node/25297 . What it meant for me is that in my template I must append
<?php print $GLOBALS['base_url'] ?>before the paths in my template.$base_pathis set in my settings.php file and theRewriteBaseis not enabled in .htaccess. My snippet now looks like this:Now my browser happily gets
http://mydomain.com/subdir/node/73regardless of templates, teasers or changes in directory.I think a handbook page should be created about this. I think I'll try my hand at writing a handbook page once I've made up lost time, if nobody beats me to it.
Limited to Clean URLs
This only works for clean URLs.