On unusual server configurations (e.g. when the document root != /, or PHP_SELF doesn't give a URI), it's necessary to set $base_url in settings.php.

The comment for $base_url says:

If you are experiencing issues with different site domains, uncomment the Base URL statement below (remove the leading hash sign) and fill in the URL to your Drupal installation.

When I read this comment initially, it wasn't clear that it applied to my situation -- and in fact to any situation when Drupal can't correctly detect the base_path.

It would be clearer to say something like

If you are experiencing issues with the URLs automatically generated by Drupal, uncomment the Base URL statement below (remove the leading hash sign) and fill in the URL to your Drupal installation.

as I've suggested in this patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pasqualle’s picture

Version: 6.x-dev » 7.x-dev
Component: base system » documentation
Status: Active » Needs review
Damien Tournoud’s picture

I like the new wording.

Dries’s picture

Looks like an improvement to me. :)

maartenvg’s picture

Patch still applies. (with quite some offset), and the new wording is a lot clearer to me. Shouldn't this patch be against default.settings.php in stead of settings.php?

gdd’s picture

FileSize
977 bytes

Yes, it should, although the backport to 6.x should use the original patch.

New 7.x patch against default.settings.php attached

Damien Tournoud’s picture

Status: Needs review » Reviewed & tested by the community

default.settings.php is also in D6. #5 is ok, based on #2 to #4.

gdd’s picture

Ah yes, you're right, my mistake.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Hm. Could we take this just a tiny bit further?

+ * If you are experiencing issues with the URLs automatically generated
+ * by Drupal, uncomment the Base URL statement below (remove the leading
+ * hash sign) and fill in the URL to your Drupal installation.

- What kind of issues might someone experience with URLs? Can you provide examples of said problems so I know when I should do this step?
- The URL to my Drupal installation? Does that mean http://localhost, or http://localhost/drupal, or http://localhost/drupal/index.php, or..?

Just a couple examples, and I think this is good to go.

webchick’s picture

Hm. Ignore that second one, I see below this that there are several examples on what the URL might look like. We still need more info on what these "issues" are though.

pnm’s picture

I couldn't remember what problems I was happening, so I tracked down a working but rarely used 5.0 installation I have.

In my case, the site is installed in a subdirectory, and the site won't work without setting $base_url. Here's what I have in settings.php:

$base_url = 'https://secure.example.com/users/foo/project';

When I uncomment that line, I have two problems: broken links and broken theme.

Broken links:

<li class="expanded"><a href="/project/node/add">Create content</a>

Browser reads this as https://secure.example.com/project/node/add
instead of https://secure.example.com/users/foo/project/node/add

Broken theme:

<style type="text/css" media="all">@import "/project/modules/book/book.css";
<img src="/project/files/color/garland-ed2c964b/logo.png" alt=".project" id="logo" />

I hope to save others from the same difficulty. @webchick -- does that help? Please let me know if you'd like me to provide anything further.

jhodgdon’s picture

Status: Needs work » Needs review

Reviving this issue...

RE #10 - This is probably a Drupal 5 error only. I have never had this type of problem in Drupal 6 or 7, although I have definitely run some sites installed in sub-directories.

So I don't know that in Drupal 7 we can really be specific about what types of problems we expect people to have. We don't expect people to have problems and need this setting, but just in case...

Setting back to Needs Review in hopes that the test bot will test out the last patch.

Status: Needs review » Needs work

The last submitted patch, 112915.patch, failed testing.

idflood’s picture

Status: Needs work » Needs review
FileSize
956 bytes

I think issues related to a wrong $base_url will always be the same. Broken theme ( wrong .css and images path ), and most internal links not working.

Here is the modification provided by this new patch

If you are experiencing issues with the URLs automatically generated by Drupal,
uncomment the Base URL statement below (remove the leading hash sign)
and fill in the absolute URL to your Drupal installation.

You will need to set Base URL if the theme looks broken and the links are not working.

You might also want to force users to use a given domain.
See the .htaccess file for more information.

jhodgdon’s picture

I think the explanation of what the issues are should go right into the first paragraph. I don't think "theme looks broken" is a very good explanation, and "links are not working" seems kind of the same as "issues with the URLs automatically generated by Drupal".

How about this to replace the first two paragraphs shown above:

If Drupal is generating incorrect URLs on your site, which could be in HTML headers (links to CSS and JS files) or visible links on pages (such as in menus), uncomment the Base URL statement below (remove the leading hash sign) and fill in the absolute URL to your Drupal installation.

jhodgdon’s picture

Status: Needs review » Needs work
idflood’s picture

New patch file based on suggestion from jhodgdon (#14)

idflood’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

I'm happy with the change (obviously, since I wrote it). Apparently idflood is also happy. I think this is pretty much a non-controversial doc change, so I'm going to go ahead and mark it RTBC.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.