Viewing your site before domain propagation
Written on March 19, 2007
So you just bought a new domain name and/or a new host and you want to see everything in action, but you can’t yet because your domain hasn’t propagated! Luckily, there’s an easy way to temporarily jump forward in time.
The quickest and easiest work-around is to just edit your hosts file so that your domain points to the IP address of your new hosting server. The hosts file is just a regular text file, but it doesn’t have a file extension like .txt attached to it. Here’s how:
Windows NT/2000/XP/Vista
In Windows NT/2000/XP/Vista, the HOSTS file most commonly located at: C:\windows\system32\drivers\etc\HOSTS
Open up that file in notepad or your favorite text editor and add two lines that looks like this:
xxx.xxx.xxx.xxx www.mydomain.com
xxx.xxx.xxx.xxx mydomain.com
“xxx.xxx.xxx.xxx” is the IP address of your new host. It’s usually provided in the welcome email, but if it isn’t, you can ping your temporary URL domain to get the IP address. “mydomain.com” is obviously supposed to be replaced with your domain name.
Once your domain name propagates, you can remove these two extra lines and your browser will be able to access your site normally.
Mac OS X
In Mac OS X, you can just open up the terminal and type:
sudo echo "xxx.xxx.xxx.xxx www.mydomain.com" >> /etc/hosts
You can use Pico to edit the hosts file again to remove the extra lines:
sudo pico /etc/hosts
Why not just use the temporary URL?
For security reasons, some web hosts won’t allow you to run server side code unless you access the site via your domain name. This work-around will let you set up things like blog software, forums, etc. using your own domain name. Some hosts will offer to let you access your site through a temporary subdomain name, but that might cause problems when you switch back to your real domain name.
Filed in: web development.