Making WordPress Domain Name Agnostic

When I was migrating this blog over to my own server at home reverse proxied at a VPS sitting somewhere, I ran into an issue where I could not figure out how the heck does one force the WordPress administration page to have a different subdomain from the where the site was installed to. Gave up on fixing it for a month or so and therefore, blog posts became… somewhat limited… Well it was limited anyways to start off with 😛

After trying out various solutions that mostly ended up in breaking the site, I’ve came across this idea:

The thread’s OP wanted a few different domains to point to his site regardless and not have WordPress further molest the URI’s being generated on the page. TL;DR the main idea was to use this:

$url = "http://".$_SERVER["HTTP_HOST"];

…inside the wp-config.php file.

And in turn:


Dang, lesson learned here – wp-config.php can be treated like a PHP script where you can call all sorts of variables, including the $_SERVER ones.

Of course, additional work is required on the nginx side to have the proxy to pass on the HTTP Host value as-is to the said internal site.

Leave a Reply

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