Title: Multiple URLs with same code base.
Last modified: September 1, 2016

---

# Multiple URLs with same code base.

 *  [charriman](https://wordpress.org/support/users/charriman/)
 * (@charriman)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/multiple-urls-with-same-code-base/)
 * Hi.. we have a couple of sites running wordpress that need to be run on multiple
   URLs.
    Our set up is this. We have a testing tier with the example URL site.testing.
   foo.com and a production tier using site.foo.com. Both are running the same code
   base that is a git repo that is moved from the testing to production.
 * Furthermore, the testing and production tiers have what we call “authoring” servers
   that share the same physical document root and database. This authoring box is
   a straight out of the box fully functional WP install running the sites off of
   the URLs: site.authoring.testing.foo.com and site.authoring.foo.com.
 * The “public” facing servers, site.testing.foo.com and site.foo.com are locked
   down to bare permissions for both the DB and the filesystem and wp-admin is locked
   down.
 * so.. in short, we need to have the same code base/DB run on multiple URLS on 
   different servers without having to hack the DB everytime.
 * Is this even possible? Drupal has no issues doing this out of the box.

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

 *  [danhgilmore](https://wordpress.org/support/users/danhgilmore/)
 * (@danhgilmore)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/multiple-urls-with-same-code-base/#post-7652404)
 * As far as I know, no, it is not possible to run different WordPress domains using
   the same database.
 * I have three domains that use the same exact code base, but different DBs.
 * dev.fqdn.tld
 * staging.fqdn.tld
 * prod.fqdn.tld
 * To do this, I just took the production database and made two copies, one for 
   dev, one for staging. I then made all the required DB changes. Since the data
   doesn’t need to be kept up to date on dev/stg, I just refresh it every 6-12 months.
 * It’s not the easiest setup, but once done, all you need to do is make sure the
   wp-config.php file points to the correct DB.
 *  Moderator [Sergey Biryukov](https://wordpress.org/support/users/sergeybiryukov/)
 * (@sergeybiryukov)
 * WordPress Dev
 * [9 years, 10 months ago](https://wordpress.org/support/topic/multiple-urls-with-same-code-base/#post-7652409)
 * Try adding this to your `wp-config.php` file:
 *     ```
       define('WP_HOME',  "http://{$_SERVER['HTTP_HOST']}");
       define('WP_SITEURL', "http://{$_SERVER['HTTP_HOST']}");
   
       ob_start( 'ob_replace_home_url' );
       function ob_replace_home_url( $content ) {
       	$home_urls = array(
       		'http://site.testing.foo.com',
       		'http://site.foo.com',
       		'http://site.authoring.testing.foo.com',
       		'http://site.authoring.foo.com',
       	);
   
       	$content = str_replace( $home_urls, WP_HOME, $content );
   
       	return $content;
       }
       ```
   
 * Most of the time, just `WP_HOME` and `WP_SITEURL` would be enough to run the 
   same install from multiple domains. The output buffering here just makes sure
   that URLs in content (images, etc.) always have the currently requested domain.
 *  Thread Starter [charriman](https://wordpress.org/support/users/charriman/)
 * (@charriman)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/multiple-urls-with-same-code-base/#post-7652411)
 * we are doing that between the “testing” and “prod”.. copying the DB back to testing
   and hacking the DB so that the URLs are correct.
 * As far as the “authoring” part, the “authoring” server and the “public” server
   are sharing the same filesystem via NFS and DB using different mysql accounts.
   The internal DNS points site.foo.com to the “authoring” box and externally that
   URL is pointed to the “public” box.
 * The BIG problem is that now on the testing side when you log in to site.testing.
   foo.com/wp-admin, it forwards to site.authoring.testing.senate.gov/wp-login and
   bombs out. I can’t figure out what the hell is going on.
    I just don’t understand
   why WP isn’t agnostic to that stuff so that everything could be relatively pathed.
 *  Thread Starter [charriman](https://wordpress.org/support/users/charriman/)
 * (@charriman)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/multiple-urls-with-same-code-base/#post-7652418)
 * Sergey,
    How does that affect what is in the DB as far as the URLs are concerned?
   Does it replace what’s in the DB with the content of the Variable?

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

The topic ‘Multiple URLs with same code base.’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [charriman](https://wordpress.org/support/users/charriman/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/multiple-urls-with-same-code-base/#post-7652418)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
