Could someone please help?

As a web developer, I expect there to be occasional issues to deal with when installing a new system like Drupal. However, this problem has me so me so angry at how much time it has wasted my time needlessly that I could spit. Please forgive me for being so upset, because I have had so much of my time wasted in this ridiculously unnecessary problem that still HAS to be solved.

All I want to do is have the base_url be a domain with the WWW. I want all links to include the "www." in the link. We do remember that, right? That's the four characters that goes between a "http://" and thew domain name. It's called "www." But in my very initial installation of Drupal with fantastic seems to have designed such a waste of time that even when I think I can easily mod it, the system purposely becomes unworkable afterward. It's just seems so NEEDLESS to be this way.

I tried editing in /includes/conf.inc

$base_url = "http://THEDOMAINHERE.com";

to instead be

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

But what happens? The site sends error headers messages.

So, edit it back and try editing /includes/common.inc to

function drupal_get_html_head() {

  global $base_url;
  $base_url = "http://www.THEDOMAINHERE.com";

(I add the last line so it has the actual domain with www.)

That works. But whenI try to change to different default themes (not even trying download stuff yet), the system refuses to let me change from the default Drupal.

So, because I need to use other themes, I try again with the first option, and it fails AGAIN.

This is the error message I get:


Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/thedomai/public_html/includes/conf.php:55) in /home/thedomai/public_html/includes/session.inc on line 10

warning: Cannot modify header information - headers already sent by (output started at /home/thedomai/public_html/includes/conf.php:55) in /home/thedomai/public_html/includes/common.inc on line 100.

Such a needless waste of my time. I have spent some of the last two days on this, and all I want to do is the simplest of tasks, to make the base url have the "www." in the domain so that it is search engine friendly.

1.) Can someone help me quickly please, a solution that will not interfere with other themes too?
2.) Can someone explain why this so very needlessly time-wasting problem had to be installed into drupal in the first place?

I apologize for being so upset, but this time-wasting for small an issue really was so unnecessary. I am developer, for crying out loud. There's understandable bugs but there's also time-wasters. This is a needless time-waster, unless someone can provide a real reason why it was ever legitimate for Drupal to make this problem so hard and so much bigger than it needed to be.

Anyone's quick help really will be appreciated. Really.

Thanks.

Comments

webchick’s picture

$base_url = 'http://example.com';

will apply against both www.example.com and example.com. There's no need to specify www in the base_url.

pobster’s picture

My sites have all got www in their links? Are you sure you just haven't missed it out in your ...sites/default/settings.php file (or whatever - not necessarily 'default')? The $base_url in there should be with "www." and then everything should be okay. No need to be messing around with any inc files...

Pobster

creviews’s picture

Thank you for replying.

All the links on a page are based on the $base_url.

So, because Drupal did not choose to let us webdevelopers easily include the www. there, all links do not go to links with the www.

THAT'S A PROBLEM (for me, anyway).

While the site will function without the www. in the links, that is not the point. When sites do not use www. in their urls, they sometimes get "double listed" in search engines. That has the net effect of splitting a site's ranking page-value IN HALF according to the search engine ranking. It is not good to have the same page listed twice in a search engine, one without www. and one with www. So, the default is to include www.

I honestly do not care about the personal preference of Drupal.org about www. I also do not care if anyone else (and I am not mean you, webchick) has other ideas about search engine rankings without a www. I am not trying to create THAT kind of other search engine ranking debate here. This issue is about MY preferences according to MY needs as a developer using the Drupal system.

To use the Drupal system, I need MY preferences to be possible. For me, that means being found in search engines with the search-engine friendlier inclusion of www. in all urls and links.

Again, please excuse me for being so upset. This is one of those very easy solutions that instead wastes time so needlessly, and I admit I am very frustrated at so great a needless waste of my time that this has been. Fantastico was supposed to simply my life in the setup for this, only to find that Drupal has made a system so ridiculously time-wasting that I cannot even solve so simple a problem as this. So, I admit I am VERY frustrated and I truly do not intend to be taking it out on anyone who is being kind to help.

To all, thank you so much for any help and understanding.

Thanks webchick.

eaton’s picture

Your site has a settings.php file. In it, the base_url is specified. Fantastic, for reasons I don't understand, sets it to 'foo.com' instead of 'www.foo.com'. Since Fantastico is a third party product and NOT something produced by the Drupal folks, I'm not sure how that constitutes "Drupal did not choose to let us webdevelopers easily include the www."

Go to your site's public_html directory. Go to the Drupal directory. Go to the settings directory, and then find the 'default' directory inside it. There's a 'settings.php' file. Edit the value for $base_url. That's it. Period. End of story.

This is the configuration work that one does when setting up a new web site -- the fact that Fantastico misconfigures it under certain situations is a bug in Fantastico, not a 'failing' in Drupal.

I notice you're using a version of Drupal that includes 'common.inc' -- that's an old version, probably pushing a year or two, and it indicates that the version of Fantastico your hosting company is using is VERY out of date.

--
Jeff Eaton | Click Here To Find Out Why Drupal "Sucks"

--
Eaton — Partner at Autogram

sepeck’s picture

Oh, now you really owe Drupal.org forums an apology.

Please contact your host provider and express to them your anger and frustration, not us. Drupal.org has NO Fantastico maintained releases. None. Drupal.org supplies a tar.gz file for you do create and update your sites. That's it. If your host provider made a Fantasico installer available to you, then they need to provide YOU with the documentation and instructions for how to use the custom, non Drupal install system that you are paying them for.

Have you read the Install.txt that comes with the Drupal installation files? Does your Fantastico installer mention the importance of cron.php and setting it up? Does it mention that you need to read the install.txt to find this incredibly important information? If it does not, then the people you are paying should explain why THEIR tools do not do this.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Geary’s picture

$base_url = 'http://example.com';

will apply against both www.example.com and example.com. There's no need to specify www in the base_url.

That's not correct. $base_url specifices the base URL that will prefix all generated links. If you want your site to include the www. in its URLs then you should include it in the $base_url. It's one or the other, not both.

Your site may accept URLs with or without the www. but that has nothing to do with whether you should put it in $base_url.

rnsi’s picture

to make the base url have the "www." in the domain so that it is search engine friendly.

Search engines require 'www' ?

sepeck’s picture

What are you talking about? Do NOT edit inc files.

The install.txt clearly states

4. CONNECTING DRUPAL

The default configuration can be found in the
'sites/default/settings.php' file within your Drupal installation.
Before you can run Drupal, you must set the database URL and the
base URL to the web site. Open the configuration file and edit the
$db_url line to match the database defined in the previous steps:

$db_url = "mysql://username:password@localhost/database";

where 'username', 'password', 'localhost' and 'database' are the
username, password, host and database name for your set up.

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

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

Now, this can be whatever you want. I have several different ones. On one site, I have $base_url = "http://www.blkmtn.org";, on another test install I have $base_url = "http://kali.blkmtn.org"; and also $base_url = "http://beta.blkmtn.org";.

If for some odd reason you are using Drupal 4.5.x series (you shouldn't), you should go with 4.6.x latest, then the SAME idea applies to the conf.php file.

You can choose whatever YOU want. I think you owe the developers an apology for flying off on a rant before asking a question on what appears to be a misunderstanding on your part.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

creviews’s picture

Thank you (and others here) for providing some assistance, in helping to solve the problem. I pre-apologized in my first post. I can grant that there could be some issues with Fantastico, but editing

$base_url = "http://THEDOMAINHERE.com";

to

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

in the /includes/conf.php file

should not have any consequence on headers. That's even in the install.txt file.

So, it seems Drupal bears SOME responsibility, even if this is an older version I am dealing with (I don't know if it is yet, although I do not have any sessions.php file or directory to edit). Still, a simple variable definition such as that should not have an header error consequence, regardless of Fantastico. Simple HTML could suffice for defining the tag, which is a Drupal issue.

I am very much appreciating the help here. Thank you.

sepeck’s picture

I have used Drupal 4.5 series and when I set the base url then, it was properly represented in the source of the web page. I have always used www in my url's for my production sites. Links in your sites won't work if your base url is not set correctly. Your's is the first report of this issue to my knowledge.

If you want people to actually look at your site, you will need to post the url.

'Pre-apologizing' when you go off on a rant really isn't applicable.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

eaton’s picture

It sounds like you accidentally left some stray carriage returns or spaces at the end of the config file after editing it. The Browser-based file editor supplied with the cpanel software many hosting companies use alongside fantastico has a nasty habit of doing this.

If a stay space or CR is left at the end of the file, AFTER the "?>" tag that closes the PHP code, that text will be shoved into the HTML headers. That's not a bug in Drupal, just the consequences of using a goofy text editor on a configuration file. While that's normal for PHP, ASP, and other script-based code, the next version of Drupal will use another technique for code files that eliminates this error entirely, enve if you DO make mistakes and leave stray characters lying around.

Again, as others have said, setting $base_url doesn't in fact impact the headers. I understand your frustration, but this is a bit like blaming Toyota because a local mechanic slashed your tires.

--
Jeff Eaton | Click Here To Find Out Why Drupal "Sucks"

--
Eaton — Partner at Autogram

creviews’s picture

Now we might be on to something. I very much appreciate that. I have indeed added a couple hard-rights in the conf.php and common/php files, using the cPanel editor. (I normally don't use that, but just did with this new site I am working with here, rather than setting up an FTP account in my FTP client.) I use hard-rights to make sense of code, so I will look into that possible impact here.

I have also taken the other good advice offered on this forum here to contact the Fantastico reseller. It is now being upgraded (at my request) and I will see what the results are later tonight or, when I get back to work on it tomorrow. If it includes the upgraded Drupal 4.6* version then I should re-start fresh with that, I would imagine.

If it does not, then I will check out the hard-right possibility.

It IS possible for me to do the whole download/install myself without Fantastico (I am capable). But since I am paying for Fantastico, and I did not want the extra time-involvement here, I prefer using the Fantastico solution.

I want to repeat my appeciation to everyone for the help and especially patience with me in my hyper frustration. I aslo repeat my apology and not wanting to take it out on anyone.

I'll keep you informed of how the situation proceeds after the Fantastico upgrade. Thanks again.

eaton’s picture

The two problems you're encountering -- Fantastico based installs having a goofy URL, and editing from cPanel introducing trailing linebreaks -- gve me fits until I figured out what was going on.

For what it's worth, I now use UltraEdit, a shareware text editor. It can edit files directly via FTP, and has clean syntax hilighting fro PHP code. I used it to clean up a few files cPanel's editor had munched on.

Fantastico is a great idea, but I've found that it's brittle if anything goes wrong. It hosed up my installation of tikiwiki in a similar fashion, but I wasn't familiar enough with that system's code to correct the problems myself.

--
Jeff Eaton | Click Here To Find Out Why Drupal "Sucks"

--
Eaton — Partner at Autogram

sepeck’s picture

Could you add your experiances to the troubleshooting section of the handbook on this? I didn't think of the cPanel adding spaces as I've never had to use it.

Additionally, www.crimsoneditor.com is a free text editor that does context highlighting and ftp direct access as well.

-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

creviews’s picture

My Fantastico has been upgaded, and the version of Drupal is now 4.6.3. I also now have a /sites/default/settings.php file to edit and no /includes/conf.php anymore.

I tested it out and the results prove that you were correct about the cPanel editor.

In /sites/default/settings.php
I used the cPanel editor to change
from

$base_url = 'http://THEDOMAINHERE.com';

to

$base_url = 'http://www.THEDOMAINHERE.com';

At the bottom in the cPanel editor, I noticed an extra blank space. Anyway, I saved it like that, but as "settings1.php" so that I not yet affect the original settings.php file.
After renaming those two files so that the new file became the usable settings.php file, I tested out the site.
As before, the headers problem happened again.

So, using that cPanel editor again, I edited the new settings.php file again. This time, I scrolled to the bottom, and deleted all spaces after the closing "?>" marker. I saved the file and tested the site once again.

There it is. The solution achieved! You were correct about the cPanel issue and its impact on the headers created by Drupal.

All links have the "www." and there are no header error messages.

Thank you so much for your vvery helpful information, and especially for doing so through my extreme frustration. For that last part, I appreciate your help even that much more. Thank you so much!

I am also even that much more appreciative of the quality of both the Drupal product and its supporters here. Thanks again.

Geary’s picture

It IS possible for me to do the whole download/install myself without Fantastico (I am capable). But since I am paying for Fantastico, and I did not want the extra time-involvement here, I prefer using the Fantastico solution.

I think you're missing an important point here.

As you build up your Drupal site, you will inevitably want to install several of the contributed modules you'll find here on drupal.org.

The procedure for installing a module is nearly identical to the procedure for installing Drupal itself. You will be going through this procedure several times.

There's no significant benefit to using Fantastico to install Drupal. It makes the initial install a bit easier, but not by much. Considering that you'll be doing the same thing a number of times to install modules, it's not much worse to do it one more time at the beginning to install Drupal itself.

TurtleX’s picture

I was having this same problem, no "www" was really bugging me. I used Fantastico to install. I changed the base_url as suggested and the "www" works now, thanks.

reikiman’s picture

I have

$base_url = 'http://www.7gen.com';

and it works fine.

This is an important issue. As one of the other commenters said, if the site can be accessed as either "example.com" or "www.example.com" then the search engines will split the indexing of the site between them two, splitting up the pagerank. I wrote an article about that here.

My host config for "7gen.com" redirects everything to "www.7gen.com" ... that's how I avoid the split indexing.

In some cases hosting providers configure websites so anything.example.com all resolve to example.com, so that someone could request goober.example.com or beans.example.com or cows.example.com or lkjhsdfljkh.example.com and the content is all returned from example.com. This is the situation you want to avoid, because of the split indexing.

I see one mistake in what the original poster said ...

The place to put

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

is in sites/default/settings.php, not in /includes/conf.inc ...

- David Herron - http://7gen.com/

vincentc’s picture

Hello,

For those more specifically interested in the topic of "www." and search engine optimisation, I started a new thread here: http://drupal.org/node/50743.

Vincent

cmsproducer’s picture

Drupal treats every incoming URL request as a different URL even if the difference is that one URL has the www and the other does not.
To address, this, you will be required to create a multiple-host folder for the secondary path and set it's base URL to the main path so that it can capture all requests to the secondary URL and send them to the main URL after the first page. This will also prevent search engines from indexing all pages with both paths and appearing like you have a duplicate website.
Please read my step by step description of the solutions in my below reply to the same question in another forum topic.

http://drupal.org/node/58597#comment-111083
-----
iDonny - Web CMS Development, Design, and Web Marketing Advice

wackimonki’s picture

Creviews, glad to hear you have found your solution. I use another technique that forces www. infront of my toultimatefreedom.com domain (under construction), even when user simply types in toultimatefreedom.com. See this redirect at http://toultimatefreedom.com.

For this to work, you need to be running on Apache with mod_rewrite enabled. Edit your .htaccess file - which should be in your www root folder, otherwise create - to include:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^toultimatefreedom\.com [NC]
RewriteRule ^(.*)$ http://www.toultimatefreedom.com/$1 [L,R=301]

But your domain name in as appropriate. Take care to escape(\) any dots in RewriteCond URL.

Having www in the front is advantageous for Search Engine rankings. In my case, all of mine Google PageRank and other reputations will be gathered for www.toultimatefreedom.com. Not spread across www.toultimatefreedom.com and toultimatefreedom.com. Also normally if a user logins in with toultimatefreedom.com, and gets redirected to www.toultimatefreedom.com, they'll need to relogin in most cases. Not so with this redirect!