I also found this from another tutorial and adding this instead of the above snippet to the wp-config.php file might work:
// For non-www domains, remove leading www
$site_server = preg_replace( '#^www\.#', '', $_SERVER['HTTP_HOST'] );
// You're on your own for the yes-www version <span class="wp-smiley wp-emoji wp-emoji-smile" title=":-)">:-)</span>
// Set URLs
define( 'WP_HOME', 'http://'. $site_server );
define( 'WP_SITEURL', 'http://'. $site_server );
This is the guide I found it from.
Tips for Hosting WordPress on Pantheon
Cheers