Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/rekall/krisgale.com/wp-includes/formatting.php on line 74

i recently had cause to change the ip address associated with a certain domain name and wanted to find a way to experience zero downtime while the dns update went global…

let’s say you had a website ‘mydomain.com’ pointing at 1.2.3.4 in your dns records, and had set up a virtual host in apache accordingly. amidst other directives in your httpd.conf you would find these:

Listen 80

NameVirtualHost 1.2.3.4:80

<VirtualHost 1.2.3.4:80>
  ServerName mydomain.com
  ServerAlias www.mydomain.com

</VirtualHost>

and, for whatever reason, you now want ‘mydomain.com’ to point to 1.2.3.5 instead. you would modify the directives shown above as such:

Listen 1.2.3.4:80
Listen 1.2.3.5:80

NameVirtualHost 1.2.3.4:80
NameVirtualHost 1.2.3.5:80

<VirtualHost 1.2.3.4:80 1.2.3.5:80>
  ServerName mydomain.com
  ServerAlias www.mydomain.com

</VirtualHost>

by doing this, you’re telling apache to be aware of incoming requests at both ip addresses but to resolve both to a single virtual host. when the dns update is known to be worldwide, you can remove all references to the retired 1.2.3.4 address.

obviously this only pertains to a dedicated hosting environments that accomodate multiple ip addresses per host.

i see no reason why this same method could not be applied to achieve a similar effect when migrating from one hosting environment to another (assuming that the old and new ip addresses are available for you to use on both servers)… you would replicate the apache settings on the new server and once the dns update is complete you would then retire the old server and remove references to the old ip address on the new one.