Seems like a strange configuration you’re going for…which begs the question: Is there a more orthodox way of achieving the desired effect?
For example, would port forwarding or a multisite installation do the trick?
I have reasons for this: this configuration is used to compare different server configurations, or even completely different web servers (a facility I have on my OS of choice), and therefore the only difference should be the server by which the application (in this case WordPress) is accessed. And each of these will access the application over it’s own port. B ecause that port is kept in the URL stored in the database, it is limiting access over that port only. I have observed that when port 81 is defined, access over port 82 will start the access, but the server on port 81 will take over at some point, and some functionality does not work…Different blogs (no problem for me – because the OS) using one database is no option either – for the same reason: the URL stored in the database will limit access over that single port….
So port forwarding nor mutisite installtion will do the trick…
Both the home and site url values are also definable via PHP constants. So if you have a means in PHP available to detect which server is being accessed, then you can change those values dynamically by setting varying constants for them. Setting constants will cause WordPress to ignore the database’s settings for those values.
So something like this at the top of the wp-config.php file, for example:
if ( $_SERVER['SERVER_PORT'] == 81 ) {
define('WP_HOME','http://example.com:81/whatever');
define('WP_SITEURL','http://example.com:81/whatever');
}
else if ( $_SERVER['SERVER_PORT'] == 82 ) {
define('WP_HOME','http://example.com:82/whatever');
define('WP_SITEURL','http://example.com:82/whatever');
}
… and so on.
Thanks, that’s just what I was looking for 🙂