For resolving staging pbs, I'm working locally with the real production domain name, but behind a proxy, so that drupal installation and web server configuration are strictly identical (on some conf the IP listening could be different, depending on the listening ip in production).
So, I had a proxy responding for http://mydomain.local, proxying to http://www.mydomain.tld, but on a local IP.
Whith nginx, in local vhost conf :
server_name mydomain.local;
set $proxied_server_name www.mydomain.tld;
set $proxied_cookie_domain mydomain.tld;
# then generic proxy conf
proxy_set_header Host $proxied_server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# My param added for drupal absolute url construction
proxy_set_header X-Proxy-Host $host;
# For headers rewriting (Location or Refresh)
proxy_redirect http://$proxied_server_name/ http://$host/;
proxy_cookie_domain $proxied_server_name $host;
# and for drupal auth, with cookies without sub-domain
proxy_cookie_domain $proxied_cookie_domain $host;
For the proxied vhost, just like in production
server_name www.mydomain.tld;
And in my settings.php
if (isset($_SERVER['HTTP_X_PROXY_HOST'])) {
$base_url = 'http://' .$_SERVER['HTTP_X_PROXY_HOST'];
}
With this conf, I can sync all drupal files AND database AND server configuration between a lot of drupal installation (dev and production in my case but could be whatever you want).