$base_url setting misleading

QuasiEvil - September 26, 2005 - 04:02
Project:Documentation
Component:Correction/Clarification
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

Set $base_url to match the address to your Drupal site:

$base_url = "http://www.example.com";

this should be changed to

$base_url = "/drupal";

or at least not "localhost/drupal";

#1

bslade - September 26, 2005 - 05:40

I assume this issue is referring to instructions in the INSTALL.txt file that comes with the Drupal installation

Actually, I thought the $base_url variable is supposed to be full URL (without the trailing slash). Eg. "http://localhost/drupal" or "http://www.example.com/mydrupalsubdir".

#2

Gábor Hojtsy - September 26, 2005 - 08:59
Status:active» by design

Base URL should be a full URL with http:// (or https:// if you use that). We are not going to change our advice, since it will not work otherwise.

#3

sepeck - September 26, 2005 - 09:32

Just a reference link for those who follow
http://www.w3.org/TR/WD-html40-970917/struct/links.html#edef-BASE

#4

fgm - September 26, 2005 - 23:22

Actually, sepeck, if you refer to the W3C spec, I think this means the "base" should be slash-terminated since the last component is a directory, otherwise it designate a leaf document instead of a path component. as shown in the W3C example you quote.

But it must not be slash-terminated, and seeing how I already had to answer questions about this, it must be a frequent issue.

So $base_url is not really an URL, but just the string from which drupal URLs are built. It would be clearer to allow the ending slash, though, to make it an actual base URL, or to mention specifically in the instructions that there must not be a slash at the end of $base_url : the examples suggest it, but it does not seem to be sufficient.

#5

clydefrog - September 27, 2005 - 19:39

fgm, you ask for instructions which ask to not include the trailing slash. From settings.php in current HEAD (and 4.6):

<?php
/**
* Base URL:
*
* The URL of your website's main page. It is not allowed to have
* a trailing slash; Drupal will add it for you.
*/
$base_url = 'http://localhost';
?>

Whether this is a good idea, I have no opinion.

#6

fgm - September 28, 2005 - 14:30

Yes, I read that: it's already clear (to you, to me, and many others) and that's why I knew the answer myself. However, seeing as I've already answered this questions several times to new site owners, and how it appears in google, it seems to be a recurring questioning. See http://plusvite.net/?a9160357 to see how much.

Maybe the issue is raised because using a rooted install (without a path) makes it think to beginners that this "no trailing slash" issue is only valid for bases like http://www.example.com instead of http://www.example.com/

Maybe using a non-rooted example like http://www.example.com/some/path would make it clearer ?

Of course, accepting both syntaxes would obviously remove the problem altogether. It would be sufficient to rewrite $base_url when it is first read, like this:

<?php
$base_url
= preg_replace ('/\/$/', '', $base_url) ;
?>

to avoid the problem altogether.

#7

nielsbom - August 31, 2008 - 08:27
Component:Installation» Correction/Clarification

Changed the component to reflect the new component categorization. See http://drupal.org/node/301443
-nielsbom

 
 

Drupal is a registered trademark of Dries Buytaert.