WordPress config snippet for dynamic domains

Quite why this isn’t how WordPress works by default, I’ll probably never know.

$domain = 'http' . (false ? 's' : '') . '://' . $_SERVER['HTTP_HOST'];
define( 'WP_SITEURL', $domain );
define( 'WP_HOME', $domain );

If anything, this snippet is for my own reference.

Prevents redirects on development / staging sites without changing the wp-config.php

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.