My primary domain name is "www.verkehrswende.net".
Secondary domain names are of the model "hamburg.verkehrswende.net" or "berlin.verkehrswende.net".

Now, if I switch on WWW prefix handling (to treat www.*.verkehrswende.net as an alias of *.verkehrswende.net), I run into a circular redirect which breaks the whole site. Obviously, "www.verkehrswende.net" is rewritten to "verkehrswende.net", which is rewritten to "www.verkehrswende.net" and so on...

What should happen instead? The active domain should first be checked against the domain table (including the primary domain). Only if it is not listed with the "www." prefix, the "www." prefix should be stripped.

Comments

agentrickard’s picture

Status: Active » Closed (works as designed)

No. That is not the design.

www.* is the abberation here. The RFC for domain names does not specify its use. example.com is preferred to www.example.com.

Either turn off the www prefixing option, solve that at the server level, or change your primary domain to verkehrswende.net.

pancho’s picture

Priority: Critical » Normal
Status: Closed (works as designed) » Active

This can't or shouldn't be by design for two reasons:

  1. In the "Default domain settings", the field description of "Primary domain name" states: "The primary domain for your site. Typically example.com or www.example.com." So it's obviously a valid option to enter a domain with the "www." prefix.
  2. We both know that the "www." prefix is unnecessary. But - no matter what the RFC says - in fact some 99% of all websites use the "www." prefix, just because it has become an informal convention and non tech-savvy users expect a domain name consisting of three parts. Teaching them that the "www." prefix was unnecessary and senseless is not what we want to do at this point - rather we want to adopt the de-facto standards of the web.

Please reconsider this.
If you really insist on this bug being "by design", then we at least need to rule out configurations leading to a circular redirect, by fixing the field description and/or adding a validation check. Then the rest of this issue wouldn't be a bug anymore, but rather a feature request.

agentrickard’s picture

Let's fix the field description then.

The module is not intended to be used by naive users who cannot self-correct this sort of problem.

There was a larg debate about a similar issue, where I basically said -- "If your webserver is configured that www.* is the default, then it is misconfigured, and I cannot help you." I stick by that.

The 'by design' part that you are fighting is a silent correction to user misbehavior. If you configure www-prefix aliasing and set your default domain correctly, users will be silently sent to the proper host. That part is deliberate and not up for debate.

agentrickard’s picture

We should also have a documentation patch for section 4.1.1 of the README.txt

agentrickard’s picture

Title: Circular redirect using "www." prefix handling » Document possible circular redirect using "www." prefix handling
nonsie’s picture

Title: Document possible circular redirect using "www." prefix handling » Circular redirect using "www." prefix handling

I have to agree with Pancho on this because if you set your default domain to use www, turn off www prefixing and solve www.example.com vs example.com at the server level you will get a message saying you have followed an incorrect link when visiting example.com.

Instead I'd prefer to set up default domain as example.com and use www prefxing however all URLs get rewritten to use example.com instead of www.example.com once user has followed a link to the site using www.example.com.
For example user lands on www.example.com, clicks on a link and the url becomes example.com/alias. For not so tech savvy users this is a big issue.
To sum it up - if www prefixing is enabled all links should use www prefix + domain name.

I realize there are two completely different issues here but they are related - finding one good solution will solve both

agentrickard’s picture

That logic seems totally backwards to me.

Non-tech savvy users don't even know how to read a URL host and generally don't care.

I still think this is a non-issue.

The message that users get is in response to #293453: Wildcard DNS - default domain, so you apparently have two groups of DA users asking for two different behaviors.

nonsie’s picture

Actually the message appears when at the server level www.example.com and example.com point to the same location yet only one (example.com without www prefixing or www.example.com) is defined in DA.
It would be nice if both example.com and www.example.com would work for the default domain without any messages.

pancho’s picture

The logic we're talking about is not backwards nor "naive", as you call it.

Non-tech savvy users don't even know how to read a URL host and generally don't care.

I strongly disagree with your argumentation. It's true that non-tech savvy users usually don't know the reasons why URLs are composed the way they are. But they do know how a URL usually looks like: http://www.example.com or http://foo.example.com. And it's exactly because they don't know the (in fact: non-existent) purpose of the "www" part, why they will get confused if something's different.
In print media (where there is no hyperlinks), the "www" part also serves as a signal word for "Look, this is an Internet address". If they would refer for example to "cocacola.eu", people wouldn't get that at first sight, as two words separated by a point is not specific enough to be interpreted as an Internet address.

But let's take a look at the results we want to have. See some examples:

Yahoo!
http://yahoo.com is being rewritten to http://www.yahoo.com
http://www.fr.yahoo.com is being rewritten to http://fr.yahoo.com
MSN
http://msn.com is being rewritten to http://www.msn.com
http://www.fr.msn.com is being rewritten to http://fr.msn.com
OpenOffice.org
http://openoffice.org is being rewritten to http://www.openoffice.org
http://www.fr.openoffice.org is being rewritten to http://fr.openoffice.org
eBay
http://ebay.com is being rewritten to http://www.ebay.com
http://www.search.ebay.com is not even resolved, only http://search.ebay.com is.

Obviously all of these four global websites take care that their URL consists of exactly three parts: prefixed by a "www" for the main website - without the prefix for all subdomains.

That's exactly what I want and, if I got him right, that's also what nonsie wants. Not more nor less.
Why? Because it is the de facto Web standard. I would call this a valid use case.

agentrickard’s picture

I like the samples in that last bit. So the issue is that our www prefix handling is universal when it should be selective?

Patches welcome. But perhaps the best fix for this is #284422: Subdomain Aliases. That patch would allow for multiple hosts to be assigned to the same domain, which is ideal.

One of the reasons I'm so testy lately is that no one seems to be testing patches, just complaining after features have been requested and committed.

And, for the record, the behavior that nonsie is describing is directly opposite the current (requested) behavior.

agentrickard’s picture

Very tempting to mark this a duplicate of #284422: Subdomain Aliases.

pancho’s picture

1.

So the issue is that our www prefix handling is universal when it should be selective?

Exactly. To allow for the behaviour we're asking for, all that needs to be done is what I proposed in my original issue:

The active domain should first be checked against the domain table (including the primary domain). Only if it is not listed with the "www." prefix, the "www." prefix should be stripped.

2.

One of the reasons I'm so testy lately is that no one seems to be testing patches, just complaining after features have been requested and committed.

I can understand that very well. I don't have a test sandbox atm and will be away for two weeks, otherwise I would have given it a closer look to come up with a patch. Also, rather than blaming those who come up with new feature requests, I'd see it as an honour how people valuate the potential of your module. Without a question, it's gonna be one of the major, say "golden" modules, soon. It solves many needs webmasters have, and they want it to become even more powerful. The issue queue of edge-case modules looks different.

3.

Very tempting to mark this a duplicate of #284422: Subdomain Aliases.

#284422 will probably be a workaround, though I've not yet come to test it. To add "www.*" as a alias for every subdomain will be onerous, though. I'd rather get the original bug fixed.

agentrickard’s picture

Patches welcome. But if you want maximum flexibility, then Domain Aliases is the way to go, and I am already committed to working that into the module.

And running the check first means that we would need to run two db queries each time (potentially), unless we ran something like:

  // Strip the www. off the subdomain, for checking, since it is always an alias of example.com
  $raw_domain = $_subdomain;
  $_subdomain = str_replace('www.', '', $_subdomain);
  $data = db_fetch_array(db_query("SELECT domain_id FROM {domain} WHERE subdomain IN ('%s', '%s')", $_subdomain, $raw_domain));

Would that work, or cause problems if people register both www.example.com and example.com -- which your approach would also do, right?

agentrickard’s picture

And in the case of the above fix, what do we do here?

  // If we stripped the www. send the user to the proper domain.  This should only
  // happen once, on an inbound link or typed URL, so the overhead is acceptable.
  if ($raw_domain != $_subdomain) {
    drupal_goto(domain_get_uri($_domain));
  }
agentrickard’s picture

Title: Circular redirect using "www." prefix handling » Change "www." prefix handling
nonsie’s picture

Just to confirm - #12 would solve my problems with www prefix handling

pancho’s picture

Now that we obviously agree that this should be fixed, it might be the best solution to wait until Ken has worked in the awesome Domain Aliases functionality. Then we can still decide on the best way to handle "www." prefixes, either leaving it separate or working it into Domain Aliases in some intelligent way!

agentrickard’s picture

Category: bug » feature

@nonsie -- you mean #13?

Well, thanks for the vote of confidence, but I am open to suggestion here. The problem is that other users asked for the reverse functionality earlier, so I do not have a good answer for the solution to this problem.

For now, you can obviously patch your installs as needed, but -- and Domain Alias is my preferred solution -- what options do we have?

The other option that I see is a per-domain setting for www aliasing, which is certainly possible.

nonsie’s picture

The ideal solution for me personally would be per-domain setting for www aliasing where if www alias is enabled it can be used throughout the site eg. if domain name is set to sub.example.com and it has an alias of www.sub.example.com users landing on www.sub.example.com will always see www prefixed domain name no matter where on the site they are (eg do not strip www for any url for the domain name if www aliasing is enabled for the domain name). It's those marketing people that apparently just can not live without www prefix:P

Haven't given Domain Alias a try yet (been too busy to get a site up and running) but I'll give it a try next week. It might provide me with a way to solve this issue however I'm a bit concerned about the extra queries that are required.

agentrickard’s picture

It's either going to be extra queries -- though I think the IN clause can handle that -- of an extra column in the database to store the prefix status.

agentrickard’s picture

Note: The #284422: Subdomain Aliases patch just became critical, because it solves the dev -> staging -> live problem for the company I work for. For instance:

If you test the site at my.testexample.com but the live site is example.com, you have to change DA settings when moving the database from staging the live. Subdomain Aliases eliminates this issue by allowing you to register both names to the same domain id.

agentrickard’s picture

Status: Active » Closed (duplicate)

After digging in, this is officialy a duplicate of #284422: Subdomain Aliases, which solves this problem very elegantly.

brianbrown’s picture

Just for the record (over a year later), the major browsers, i.e., Internet Explorer, Opera, Google Chrome, and the precious Firefox, will ALL attempt www.example.com if example.com does not resolve.
And, by the way, note how even the Drupal links autodiscovery in THIS VERY POST only converts links containing "www."
-B