By jfurry on
I've got drupal installed in a test directory on my webserver while I perform my migration. I've updated my $base_url to be
$base_url = 'http://www.myhost.com/test'; // NO trailing slash!
Once I've fully migrated/tested everything, my plan was to copy all the drupal files to the root directory on my webserver and update $base_url.
However, I'm having trouble creating basic links. I have the following valid link
http://www.myhost.com/test/about
If I reference it like this:
About the actual link that gets generated is:
It seems like the $base_url is being ignored when the link is being generated.
Is there a better way to do this? Or am I misreading what base_url should be doing.
Thanks!
Comments
Sorry
Sorry, first post and messed up the formatting. Here's what I mean to ask
I've got drupal installed in a test directory on my webserver while I perform my migration. I've updated my $base_url to be
$base_url = 'http://www.myhost.com/test'; // NO trailing slash!
Once I've fully migrated/tested everything, my plan was to copy all the drupal files to the root directory on my webserver and update $base_url.
However, I'm having trouble creating basic links. I have the following valid link
If I reference it like this:
The actual link that gets generated is:
It seems like the $base_url is being ignored when the link is being generated.
Is there a better way to do this? Or am I misreading what base_url should be doing.
Thanks!
no 100% solution
$base_url does NOT dynamically rewite the content of the page to fix your problem. (a filter probably could do that, but currently doesn't)
I understand your problem completely, but it's been a web dev problem since forever.
Drupal < 4.6 used to use the HTML BASE attribute to get around this, but that has a whole heap of other side effects, and it's good to be gone.
In your case, "/about" always (and always will) refer to http://your.server/about.
You cannot use relative links (like I'd prefer) when using clean urls, or viewing the same node in different contexts.
A very messy fix would be
href="<?php print $base_url; ?>/about"under php.A slightly better approach would be to use token or reptag to let you go
href="%base_url/about"Me, I usually find it all too much work, and impossible to explain to clients, so I make my dev sites on different ports or subdomains and just use /root-relative links :)
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
What about drupal: scheme?
A convention that seems to be widely used in other wiki-type things is to introduce a new scheme for links that target the current wiki. E.g. you write something like <a href="wiki:wiki-relative-path"> The use of the wiki: scheme differentiates these from conventional links, which are understood to point outside the wiki. On output, the wiki: links are translated into the appropriate conventional link for the client browser to handle in the usual way.
Does something like this already exist for Drupal? If not, where would I look to start thinking about adding it?
I ask because we already hit this problem "head on" when we went to relocate our drupal world to a different root location, and the prospect of patching every single link on the site later when we have a lot of them is (err, um) not appealing.
Not a bad suggestion. It's
Not a bad suggestion.
It's already possible to use reptag that way. Possibly token also, I've not looked at it specifically.
I do think it's be great to get a convention like that set up. It'd be simpler to explain to folk too - This means your site homepage, make all links from under it!
.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Like dman suggested, try
Like dman suggested, try testing it at http://test.example.com instead.
Thanks!
Ok, I'll try a subdomain, that seems like the simplest way to get my test up and running.
Thanks!
Subdomain works like a charm
Thanks again for the suggestion. Created a subdomain for my test drupal install and now I can properly use relative paths which I won't have to change once I move to my main domain.