Following: http://lists.drupal.org/pipermail/development/2008-November/031378.html

If user-friendliness is a desired goal, then maybe we should uncomment one of the suggestions in .htaccess, regarding the access to the site with/without the www prefix (preferably keeping the one WITH www).

Having them both creates duplicates (any seo expert around here to explain the effect of that?), and by default it is not sharing session cookies (last time I checked at least), which leads to confusions ("hey! why am I thrown out of that site?!").

Savvy users will probably know how to change the values, if they really need to.

Comments

Vacilando’s picture

Subscribing.

Gábor Hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

For reference here is the affected code.

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/... will be redirected to http://example.com/...)
  # uncomment and adapt the following:
  # RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
  # RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Reasons why it is impossible to comment any of these out:

- There is no guarentee that the site is actually on a first level domain at all... it could be at http://joe.sales.example.com just as well.
- Multilanguage support includes subdomain support for stuff like en.example.com and it.example.com, which should be kept (and results the site being called with different domains)
- The rules require knowledge of the exact domain name of the site (eg. britneyspears.com, drupal.org, etc). This is not something we can put into the distribution, right?

I am not sure how you envision to go forward with this??

Gábor Hojtsy’s picture

Oh, also, there is no guarantee that both without and with www is available and that both domains would lead to the same webserver vhost at all. I've seen several hosts, where they did not actually point to the same website (vhost).

jbrauer’s picture

A change to INSTALL.txt and pointing to some documentation in the getting started guide would be a much better solution.

In addition to the issues in #2 and #3 there are multisite installations that cannot have this done in .htaccess. They can do similar things in vhost config etc., but it can't be done in a .htaccess file used by multiple sites.

Also we should not make the "preferably with www" choice... My (and I think many other sites) preferences is for without www and wouldn't like to have to remember to change this.

So -1 to changing this part of .htaccess.

+1 to documenting it in an easier way for new users to understand what to do, how to change the rule and why they might want to.

z.stolar’s picture

I agree with the above.
Mainly the need to know in advance the site URL...

However, while we're here, we might as well add an explanation to the file, stating the risks of having the site available in two domain names. For example:

- Not sharing the session cookie, which might confuse users when accessing once to www.example.com, and once to example.com
- Having duplicate content in search engines, which weakens the weight and ranking of a single page (since it appears "twice")

Apart from that, I don't see any other solid excuse to currently keep this issue open, considering the above request.

kbahey’s picture

Why is this a problem that needs to be solved in Drupal?

I solve it at the Apache level by using this in the vhost. Note the redirect permanent. And if you are, like me, against www as a prefix, then you can do it the other way around.

<VirtualHost *>
 ServerAdmin webmaster@localhost
 ServerName www.example.com
 LogLevel warn
 ServerSignature Off
 DocumentRoot /var/www
 CustomLog /var/log/apache2/access-www.example.com.log combined
 ErrorLog /var/log/apache2/error-www.example.com.log
 <Directory /var/www>
  AllowOverride All
  Options MultiViews -Indexes Includes FollowSymLinks
  Order allow,deny
  Allow from all
 </Directory>
</VirtualHost>

<VirtualHost *>
 ServerAdmin webmaster@localhost
 ServerName example.com
 RedirectPermanent / http://www.example.com/
</VirtualHost>

This leaves out shared hosts, where you can add a $base_url with the canonical URL you want, and a redirect using cPanel too. You can even add a RedirectPermanent to your .htaccess, and all we have to do is document it.

z.stolar’s picture

it's not a matter of "solving it in Drupal". It's more of a matter of rendering Drupal, even better than it is now, as an SEO goodness, and of going one step further towards the users, who normally won't get anywhere near Apache configuration.
These users [are | should be] the majority of Drupal users, and we should make life easier for them.

Maybe a process similar to the one done in settings.php during installation, can be done here, to aid the non-technical users to choose the right configuration for them.

Edit: Khalid, I didn't notice your last line. Yes - Documentation is probably a good intermediate solution.

dman’s picture

Even those SEO 'risks' are matters of opinion, I'd say
1. Cookie domains can be set and shared at the appropriate high level, (but at a PHP level I think). example.com can set a cookie that is available to www.example.com, but not vice versa. IIRC.
2. Successful search engines are smart. But even the dumb ones know that if example.com/path and www.example.com/path have the same content, they are the same page. Really dumb ones don't even compare content and make that assumption. SEO mythology about splitting your pagerank that way is bogus.

And I prefer, recommend and document sites without the www, so making the choice for me rather than offering the choice will disappoint as many folk as it helps.
Any more visible docs are good tho!

Pancho’s picture

Title: Have www as an prefix to domain name by default (currently commented out in .htaccess) » Have www. as an prefix to domain name by default (currently commented out in .htaccess)
Version: 6.x-dev » 7.x-dev
Status: Postponed (maintainer needs more info) » Active

Don't know if and how we can solve this, but it would be nice. Anyway it's active not 'needs more info'. Moving to D7 as well.

Anonymous’s picture

Status: Active » Closed (won't fix)

I agree that this is a server level issue.