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";

Comments

bslade’s picture

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".

Gábor Hojtsy’s picture

Status: Active » Closed (works as designed)

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.

sepeck’s picture

fgm’s picture

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.

ezheidtmann’s picture

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

/**
 * 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.

fgm’s picture

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:

$base_url = preg_replace ('/\/$/', '', $base_url) ;

to avoid the problem altogether.

nielsbom’s picture

Component: Installation » Correction/Clarification

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