[wp-hackers] WP Development & Production Sites

Ankur Oberoi aoberoi at gmail.com
Fri Dec 17 07:39:23 UTC 2010

> Okay, let's say your production site is live.example.com and your
> staging site is stage.example.com.
> On your staging site, you set it up to think it's the live site, with
> the live URL. This is to make it identical in content and database and
> such with the live site.
> Then, in some file that is not going to the live site (wp-config, any
> plugin, etc), you'd do something sorta like this:
> ob_start('my_callback');
> function my_callback($out) {
>   return str_replace('live.example.com', 'stage.example.com', $out);
> }
> Output buffering. It's easy.
> http://php.net/manual/en/function.ob-start.php
> -Otto


I just got around to trying this out. At first I thought this was perfect and I took ur advice on modifying the hosts file to point to my own machine for the live URL. Then I tried to access wp-admin and I have an issue, maybe you've dealt with this so you can help me out.

I (will) have a staging server at 'stage.example.com' and the site lives at 'example.com', so I set my output buffering callback function like this:

function my_callback($out) {
  	str_replace('example.com', 'stage.example.com', $out);
	return str_replace('http://example.com', 'http://stage.example.com', $out);

I am trying to be extra cautious about the url, although i don't like the fact that if anywhere in my content i talk about example.com it will automatically be changed to stage.example.com, but in this case that won't happen so lets just ignore that.

on my staging machine I added a line to /etc/hosts: stage.example.com

the machine also has a vhost running whose ServerName (apache specfic i guess) is set to stage.example.com and points to the directory in which the site lives.

I am pretty sure I did all the steps right, but what would it take for my client to be able to visit stage.example.com/wp-admin in order to see the admin section as usual?

More information about the wp-hackers mailing list