Title: double wordpress installation with same database and same posts
Last modified: August 21, 2016

---

# double wordpress installation with same database and same posts

 *  [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/)
 * want to create two different web site address (www.mysite1.com) and (www.mysite2.
   com) that use the same database and have the same posts content
    In config.php
   I changed the prefix of the two instalation by wp1_ for [http://www.mysite1.com](http://www.mysite1.com)
   and wp2_ for [http://www.mysite1.com](http://www.mysite1.com) and it did not 
   work
 * both websites (www.mysite1.com) and (www.mysite2.com) have a different web adress
   and a different theme and a different logo but the same posts

Viewing 13 replies - 1 through 13 (of 13 total)

 *  [Ben Meredith](https://wordpress.org/support/users/benmeredithgmailcom/)
 * (@benmeredithgmailcom)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4528966)
 * Is that the real URL (mysite1.com, mysite2.com) or can you give us a link to 
   the real one?
 * Bigger picture questions:
 * Are you trying to have two sites that mirror one another? WordPress is not set
   up that way. It is possible to use the same database on two sites (called multisite),
   but not the same tables within that database (for example, the wp_posts table
   that stores all the data from posts/pages) on two different sites.
 * In order to have the same posts show up on two different sites (a questionable
   practice in terms of search engine optimization anyways) you have to have two
   databases that mirror one another. (and that’s extremely high-level code that
   we cant help with on these forums)
 * Does that make sense?
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4528997)
 * hi Meredith , actualy i’m working on localhost
    I want my two different sites
   to display same posts . is that really extremely high-level code ?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529018)
 * I’d like to know why you want both sites to have the same content?
 * It’s been discussed many times on here, and on pretty much every other web/SEO
   board around, that two sites with the same content will be penalised or dropped
   completely by Google, so you’ll get no search traffic at all – ever.
 * This may or may not by a concern for you, but it’s a very big concern for most
   webmasters out there.
 *  [chaturaka](https://wordpress.org/support/users/chaturaka/)
 * (@chaturaka)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529020)
 * One of the nice things about WordPress is the great number of hooks in the code
   allowing you to extend or override core functionality.
 * One way to approach this problem would be to set an Apache environment variable
   in your vhost file for each site that could be used in the WordPress bootstrap
   process to over-ride the theme and base URL setup.
 * e.g. in Apache vhost add:
 * `SetEnv WP_CONTEXT main`
 * and
 * `SetEnv WP_CONTEXT mobile`
 * (or equivalent if you’re using a different webserver).
 * In wp-config.php:
 *     ```
       switch ($_SERVER['WP_CONTEXT']) {
           case 'main':
               define('WP_HOME','http://maindomain.com');
               define('WP_SITEURL','http://maindomain.com');
           break;
   
           case 'mobile':
               define('WP_HOME','http://mobile.maindomain.com');
              define('WP_SITEURL','http://mobile.maindomain.com');
           break;
       }
       ```
   
 * This will set the base URLs based on the environment variable.
 * Then in plugin add the following filters:
 *     ```
       add_filter('template', 'change_theme');
       add_filter('option_template', 'change_theme');
       add_filter('option_stylesheet', 'change_theme');
   
       function change_theme()
       {
           switch ($_SERVER['WP_CONTEXT']) {
               case 'main':
                   return 'main';
               break;
   
               case 'mobile':
                  return 'mobile';
               break;
       }
       ```
   
 * This needs to be in a plugin so that it’s loaded before the normal theme loading
   process (functions.php is part of the theme and hence too late). These filters
   will intercept and over-ride the theme settings from the database.
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529155)
 * is it working for 2 différent website with the same database?
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529160)
 * The biggest problem with running two sites off the same database with the same
   content is that all of the links and images in your posts/pages are hard-coded
   ot the domain that they are uploaded/inserted by. This means that if you insert
   a link to a page, it goes t othe page on that site only, and it will never link
   to the same page on the second site.
 * And again, why do you want two different sites with the same content?
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529168)
 * I have two facebook page with two different names, I want to use them for selling
   my products
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529169)
 * I can edit/change single.php for each website , i’am ussing custom post types
 *  [Ben Meredith](https://wordpress.org/support/users/benmeredithgmailcom/)
 * (@benmeredithgmailcom)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529171)
 * What prevents you from selling the product on the two facebook accounts (which
   is weird and shady, by the way) but using the same WordPress website?
 * Are you pretending to be two completely different people selling the same products?
 * There are so many confusing things about this whole scenario.
 * The short answer is that you’ll be hacking core code, which is frowned upon here
   for many reasons, and whatever gain you get by “streamlining” your two websites
   will certainly be lost in terms of SEO and general don’t-be-a-scammer web etiquette.
 * Afraid I can’t help with that.
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529173)
 * SEO is not my problem guys ):
 *  [mon3](https://wordpress.org/support/users/mon3/)
 * (@mon3)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529174)
 * So basically a multi-site type of thing? wpmudev has a plugin for that but it
   cost money [https://premium.wpmudev.org/project/multisite-content-copier/](https://premium.wpmudev.org/project/multisite-content-copier/)
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529179)
 * hi mon3 ,nah this is about multisite but thx anyway
 *  Thread Starter [larzo92](https://wordpress.org/support/users/larzo92/)
 * (@larzo92)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529185)
 * guys c’mon need help …

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘double wordpress installation with same database and same posts’ is closed
to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [prefix](https://wordpress.org/support/topic-tag/prefix/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 13 replies
 * 5 participants
 * Last reply from: [larzo92](https://wordpress.org/support/users/larzo92/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/double-wordpress-installation-with-same-database-and-same-posts-1/#post-4529185)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
