How to test a website whilst it is in developmentIf you're developing a replacement website either for yourself or a client, you may find it difficult to access the development version when you domain is not pointed at that hosting plan yet. Some hosts, us included, will give you a temporary URL you can access your account on - but what if you have the domain name set up in your application such as WordPress? Or what if you have lots of URL rewrites for search engine optimisation? The temporary URL isn't much use then. Fortunately, there is a solution...
There are a few basic ways to do this, but with a lot of today's PHP software they don't work too well because of all the rewrite rules that are installed within websites that often re-write URLs to make them more search engine friendly.
The best way to do this is to modify the 'hosts' file on the workstation that you're using. When a computer resolves a domain name (e.g yoursiteatkualo.com) to an IP address (e.g. 22.214.171.124), it first looks at its local hosts file for any static mappings before it goes to the internet to look it up. This means that by defining a static mapping in your local hosts file, you can 'trick' your computer and therefore your website browser(s) into accessing the domain name on the new IP address, without affecting the current live website on the domain for any regular users. It only affects your local workstation.
The location of the 'hosts' file varies depending on your Operating System, however here is a list of the most common ones.
Windows : %SystemRoot%\system32\drivers\etc\hosts (usually, the system root is C:\Windows, so your hosts file will likely be C:\Windows\system32\drivers\etc\hosts)
Linux & MacOS : /etc/hosts
In order to point the domain, you'll need to know the IP address on our systems that it is being hosted on. This can likely be found in your welcome email, however if you're unsure please feel free to ask us via our helpdesk. Once you know the IP address, the entry that you'll need to add will look like this (using the sample details above):
126.96.36.199 yourdomainatkualo.com www.yourdomainatkualo.com
This adds an entry that will point yourdomainatkualo.com (with and without the www. prefix) to 188.8.131.52.
You may need to clear your cache so that the changes take effect (see here and then here).
Finally, when you've completed testing or developing, remember to remove the entry or comment it out so that you may see the actual website once again.
Operating System Specific Notes
Windows 7 - you may need to run Notepad with administrative privileges in order to edit the file. To do so, find 'Notepad' in your start menu in Windows, and then right click to 'Run as Administrator' option. You can then navigate to the file via the 'File -> Open' option to edit it.
MacOS X - you will need your systems' administrative password to make changes to this file. Open the 'Terminal' application, and then type 'sudo pico -w /etc/hosts'. When prompted, supply your administrative password and then make the changes as above to the file. To exit, type 'Ctrl' then 'X' together and then you'll be prompted to save your changes.
You can read more about the hosts file by clicking here to view its related article on Wikipedia.