I am running a site for a German NGO under the domain sub.example.org
.
Recently, I added sub.example.ch
for its Swiss spin-off.
Both (sub-)domains are pointing to the same physical location, a WP install (not multisite).
I have it setup such that sub.example.ch/register
, for instance, will correctly show the content found under sub.example.org/register
.
However, when a Swiss visitor surfs the site using regular on-site links, he or she will inevitably end up on the “regular” domain, since those utilize the “WordPress address” (or “site address”) as defined in general settings, either via get_home_url
or get_site_url()
(or their less-deep get_bloginfo()
equivalents).
Ideally, I’d like the visitor to keep surfing under the domain that he or she used to reach the site. Hence, I suppose I’d have to somehow filter the return value of the mentioned functions. A filter, which, as far as I know, does not exist.
-
Does anybody have experience with this sort of thing and a decent solution handy?
-
Is this maybe a dumb idea and I should let it go in the first place?
You could filter the option requests for the host.
In your
wp-config.php
below the line â¦â¦ add the following lines:
add_filter()
is not available earlier, and you should keep such code in yourwp-config.php
. I donât know if there are side effect or cases where it doesnât work. Should not happen, but test it thoroughly.