[wp-trac] [WordPress Trac] #50100: Native domain mapping does not handle both WWW and non-WWW versions of a domain - both should work

WordPress Trac noreply at wordpress.org
Wed May 6 10:25:14 UTC 2020


#50100: Native domain mapping does not handle both WWW and non-WWW versions of a
domain - both should work
--------------------------------+-----------------------------
 Reporter:  jodamo5             |      Owner:  (none)
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Networks and Sites  |    Version:  5.4.1
 Severity:  normal              |   Keywords:
  Focuses:  multisite           |
--------------------------------+-----------------------------
 The native domain mapping only works for the exact domain entered, and
 does not automatically redirect www to non-www (if a non-www was entered)
 or non-www to www (if a www domain was entered).

 == Examples

 === Example – “WWW” Mapped Domain:

 * Multisite core domain: `xyz.com`
 * Subsite original address: `abc.xyz.com`
 * Subsite once mapped: `www.abc.com`

 **What happens:**

 * Visiting `www.abc.com` shows the site (as expected)
 * Visiting `abc.com` does not show the site – it instead shows the
 multisite registration page – `xyz.com/wp-signup.php?new=abc.com`

 **What I expected to happen:**

 Visiting `abc.com` should automatically redirect to `www.abc.com` because
 that is the mapped domain


 === Alternative Example – non-WWW Mapped Domain:

 * Multisite core domain: `xyz.com`
 * Subsite original address: `abc.xyz.com`
 * Subsite once mapped: `abc.com`

 **What happens:**

 * Visiting `abc.com` shows the site (as expected)
 * Visiting `www.abc.com` does not show the site – it instead shows the
 multisite registration page – `xyz.com/wp-signup.php?new=www.abc.com`

 **What I expected to happen:**

 Visiting `www.abc.com` should automatically redirect to `abc.com` because
 that is the mapped domain.

 == Possible Arguments
 === Technical Arguments vs Human Experience

 One technical argument presented for this is that `abc.com` and
 `www.abc.com` are two distinct domain entities. Just like
 `images.google.com` and `fonts.google.com` are two distinct domain
 entities. While this argument is ''technically'' correct it is not correct
 ''practically'' as it  ignores best practice and the human-user element of
 how websites have worked for 20 years.

 While "www.google.com" and "google.com" are two technically different
 domains, in reality no website owner should ever point these to two
 different sites! It would be ridiculous to do so.

 So while other subdomain entries do not need to be allowed for, there
 should be an automatic allowance for "www" and the root domain to
 automatically redirect between each other based on whether the mapped
 domain was entered with www or not.

 === Should This Be Core?

 A key question with every enhancement request is whether or not something
 should actually be part of WordPress core, or be left to a plugin.

 The official [https://wordpress.org/support/article/wordpress-multisite-
 domain-mapping/ domain mapping documentation] states:

 > Before WordPress 4.5, domain mapping requires a domain mapping plugin
 like WordPress MU Domain Mapping.
 > In WordPress 4.5+, domain mapping is a native feature.

 So the official recommendation is that core can take care of the domain
 mapping on multisite installations.

 However, there is no mention anywhere on the page that this native domain
 mapping will not work for the standard behaviour of automatically handling
 both the www and root versions of the domain. Since this is the way all
 websites normally work, if it was the intentional behaviour it seems to be
 a glaring omission from the documentation.

 I reason that WordPress multisite users would not expect to map abc.com
 and have www.abc.com fail to load the site, and instead get redirected to
 the multisite registration page.


 == Possible Solutions

 === Could it be solved through htaccess rules?

 When setting up a multisite the steps include changing the contents in the
 htaccess file.

 Redirecting between www and root for domains can be done at an htaccess
 level, so could a clever htaccess rule be written to handle this for all
 mapped domains that get added to the site?

 If this approach was to be used, it would need to handle a wide variety of
 scenarios:

 * It would need to exclude the core multisite domain and all its sub-
 domains from being affected. (Only mapped domains should be affected)
 * Having a blanket "redirect root to www" for all subdomains, or vice
 versa is not ideal. Some mapped domains might specifically want to be
 shown with www or without www. A blanket htaccess rule wouldn't know
 whether the user mapped a www or root domain.

 So I don't think setting a blanket rule from .htaccess is a good solution.

 === PHP Redirect
 I believe the solution needs to be PHP specific.  The redirection should
 apply to mapped domains only, and should assess whether the mapped domain
 begins with "www." or not.  If not, then WordPress should redirect www
 traffic for that domain to the root version of that domain.  If it does
 begin with "www." then traffic seeking the root domain should be
 automatically redirected to the www domain.


 == Related Tickets
 **#48197 Add support for assigning multiple domains to a single site in
 multisite**

 Ticket 48197 is asking for much more than this ticket of mine is
 suggesting. While it could be used to solve this problem, it is
 functionality that extends beyond where core WordPress needs to serve. It
 is more of a nice-to-have that can be served by plugins. Therefore,
 although it is related, I see ticket 48197 as having less valid arguments
 for being included in core, which is why this posted as a separate ticket.


 == Summary

 The current domain mapping that is built into core has this enormous
 problem in usability. Site owners would not expect their site to work for
 "www.abc.com" but send visitors who entered "abc.com" to a registration
 page for the multisite. This is a bad user experience.

 When using multisite native domain mapping, WordPress should automatically
 account for www and non-www and redirect between the two, depending on
 whether the domain entered started with www or not.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50100>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list