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?

2
  • 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
    Commented Mar 23, 2012 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
    Commented Mar 23, 2012 at 21:00

4 Answers 4

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
  • Why not use the network feature? codex.wordpress.org/Create_A_Network Commented Apr 18, 2012 at 21:44
  • this is for development & testing purposes, the multi-site feature wouldn't be applicable here.
    – GSto
    Commented Apr 19, 2012 at 20:52
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.

1

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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