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.
Comment | File | Size | Author |
---|---|---|---|
#16 | 112915-comment-base_url-16.patch | 1.05 KB | idflood |
#13 | 112915.2.patch | 956 bytes | idflood |
#5 | 112915.patch | 977 bytes | gdd |
settings.php_.patch | 881 bytes | pnm | |
Comments
Comment #1
PasqualleComment #2
Damien Tournoud CreditAttribution: Damien Tournoud commentedI like the new wording.
Comment #3
Dries CreditAttribution: Dries commentedLooks like an improvement to me. :)
Comment #4
maartenvg CreditAttribution: maartenvg commentedPatch 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?
Comment #5
gddYes, it should, although the backport to 6.x should use the original patch.
New 7.x patch against default.settings.php attached
Comment #6
Damien Tournoud CreditAttribution: Damien Tournoud commenteddefault.settings.php is also in D6. #5 is ok, based on #2 to #4.
Comment #7
gddAh yes, you're right, my mistake.
Comment #8
webchickHm. Could we take this just a tiny bit further?
- 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.
Comment #9
webchickHm. 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.
Comment #10
pnm CreditAttribution: pnm commentedI 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:
When I uncomment that line, I have two problems: broken links and broken theme.
Broken links:
Browser reads this as https://secure.example.com/project/node/add
instead of https://secure.example.com/users/foo/project/node/add
Broken theme:
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.
Comment #11
jhodgdonReviving 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.
Comment #13
idflood CreditAttribution: idflood commentedI 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
Comment #14
jhodgdonI 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.
Comment #15
jhodgdonComment #16
idflood CreditAttribution: idflood commentedNew patch file based on suggestion from jhodgdon (#14)
Comment #17
idflood CreditAttribution: idflood commentedComment #18
jhodgdonI'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.
Comment #19
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks!