1

Is there a way to use the same database, tables and all, with two different domains? For example, two employees each have thier own subdomain to develop / test with, so there may be two instances of a site:

jack.example.com/test_blog/
jill.example.com/test_blog/

however, since the base url is stored in the database, it seems that it would require two distinct databases for this set up to work properly. Is there any way around this?

  • If all you want is different domain, some apache rewrite rules should be enough. But depending on what your end goal is, multisite setup will probably work better for you. I.e. what do you want the two sites to share? – ltfishie Mar 23 '12 at 18:40
  • if you don't need the sites to share data and just use the same database you can set up both sites with the same database but different prefix like: jack_, jill_ – Bainternet Mar 23 '12 at 21:00
4

Turns out that instead of relying on the Database for a URL, you can set it in the config file, which solves the problem I was having, like so:

define('WP_SITEURL','http://jack.example.com/test_blog/');

and then I set use a different config file for the other instance.

soruce: http://codex.wordpress.org/Editing_wp-config.php#WordPress_address_.28URL.29

2

Wordpress has native support for running multiple instances within one Wordpress install since the release of 3.0. Creating a network, previously 'Wordpress Multisite or MU' has full documentation here. This would allow you to have the sub-domains as well as one easy to manage admin.

0

Use a different prefix for each WP installation. In this way all the tables will be prefixed with the prefix of your choice.

0

Should someone else need this... I had a requirement to setup a test environment where we could test code but the actual content needed to be identical and constantly synced with the live site (we only made use of the WordPress API for this project).

There were a few options such as MYSQL database replication however it turns out the simplest was to just to set the second instance (our test site) of WordPress to connect to the database of out live site and then we used the following on the test site in the wp-config.php file.

define( 'WP_HOME', 'http://xxxxxxxx.com' );

Above we define the domain of our test site. This allows the test site to grab the content from the live site but override the url so it works without any problems.

Two WordPress installations getting their content from the same tables in the same database from one server and a single point of entry/management.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.