Force WordPress hostname independent of configuration

Just add this to your wp-config.php:

<?php
define('WP_SITEURL', sprintf('http%s://%s', empty($_SERVER['https']) ? '' : 's', $_SERVER['HTTP_HOST']));
define('WP_HOME', WP_SITEURL);