With shared hosts, generally when you create a site, you get a temporary url which you can use for testing purposes even if the DNS settings on your domain name haven’t yet been pointed to your shared host… with a VPS, you’re on your own. You don’t get a temporary url so you’re forced in to coming up with your own solution. I have a VPS running Ubuntu with Digital Ocean, so i’ll share how i get around the temporary url problem…
Stop talking nonsense. Explain the problem.
Let’s say you own a website called Google.com (lucky you). You have it hosted on a shared hosting package at GoDaddy. It’s quite popular and people are relying on it to be up 24/7. But you’ve decided that you want to move the site to your own dedicated server or VPS in order to handle the growth. You can’t afford to dick around with settings and have it go offline indefinitely while you try to figure out how to move it. The transition has to be a seamless experience for the end user…
This is where temporary urls come in handy. So your website might be Google.com but with a shared host you might be able to access the live site at 1245.godady.com/junkt~ed7291. So you can do all your testing and pre-launch checks there, just like a pilot does before taking off. Changing the DNS settings on your live domain name is like barreling down the runway at full throttle, beyond the point of return. After you’ve taken off is not the time to be testing whether everything is functioning correctly.
So as mentioned earlier, if you have your own VPS, you probably won’t be able to create temporary urls easily. But then again, you probably don’t need to…
Give me the solution.
In short, if i’m moving a site to a new location, i basically want to see the site working live in it’s new home before i change the DNS settings on the domain name. Or using the pilot analogy, i want to carry out all pre-flight checks and know that i’ve done everything i can to ensure the plane will fly before i take off. I don’t really need a temporary url, i just need to be able to access the website in it’s new home. How can i do that without a temporary url you ask?
Well, you can trick your PC or local network in to thinking that Google.com is hosted on [insert IP address here]. So when you type in google.com in to a browser, you’ll be diverted to [your IP] which in turn renders your website. This trick involves editing what’s called a ‘hosts’ file locally. On Windows, you’ll find it by going to Windows > System 32 > Drivers > etc (there’s a folder called ‘etc’, i don’t mean ‘etcetera’).
So if you want to test out your website in its new home before you change DNS settings (and why wouldn’t you?!) then you could edit the hosts file to include a line like so:
or just to clarify…
[IP address of new host] + [space] + [url]
So what happens here is that once saved, any requests for google.com will direct to the IP 131.253.
The transition for users will be seamless although it’s a little more complicated if you’ve a busy site with lots of users storing stuff in a database (in that case you’ll probably have to take the site offline briefly in order to prevent data from being lost during the transition from old host to new host).
But that, in a nutshell, is how you overcome the problem of not having a temporary url to play with. Don’t forget to remove the rule you just entered in to the hosts file too after you’re done. Generally there are 3 reasons why you’ll edit the hosts file:
- To restrict access to certain sites or just to prank people…
- To prevent software from reaching authentication servers… would you like to register your software and get free updates? No. Of course not. Not if you’re using pirated software. Hackers / pirates / privacy conscious folk may want to edit the hosts file… some for legal reasons, others for not so legal reasons.
- As I’ve pointed out here, for development / testing purposes.
So there you have it. A hacked solution which may not be pretty, but feel free to offer suggestions or alternative solutions in the comments 🙂