Why is WordPress not using $_SERVER['SERVER_NAME'] for 'WP_SITEURL' and 'WP_HOME' as default?

I came across this site and I was wondering why WordPress isn't using this as default:

define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME']);
define('WP_HOME',    'http://' . $_SERVER['SERVER_NAME']);

So nobody has to change this values when changing the domain. Is there any reason or disadvantages of using this?

Topic wp-config Wordpress

Category Web


With these constants defined, your WP site will work both with and without the preceding www. (as well as on any other URLs that correctly resolve to the site, like hosting-provided staging URLs, etc), which search engines will penalize as duplicate content.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.