If you’re like me and build your site on a temp URL before changing the DNS, you’re familiar with accessing your site through http://111.222.333.444/~username/. I usually don’t have any problems with this till today, when I migrated a site from a standalone hosting server into a new server that hosted multiple sites via addon domains.
Because my addon domain folder is located above public_html, I can’t access the temp URL through http://111.222.333.444/~username/addondomain like how many other sites have advised. All I get is a 404 not found from the main http://111.222.333.444/~username/ site. That’s bloody frustrating.
After much Googling and failing, I decided to turn to ServerFreak’s amazing support team for help. They were so generous to help; see below for the solution:
STEP 1 – Edit your hosts file
Assuming you’re running Windows – see here for Mac instructions. Yes, this is the same hosts file you use to *ahem* modify some Adobe programs.
- On your computer, go to C:\windows\system32\drivers\etc\hosts
- Copy the file to Desktop or some other folder.
- Open with -> Notepad, add the following two lines:
[your server’s IP] [your www addon domain], e.g. 111.222.333.444 www.addondomain.com
[your server’s IP] [your addon domain], e.g. 111.222.333.444 addondomain.com
- Save the file – be careful not to add a suffix e.g. hosts.txt, save it just as “hosts”.
- Copy and paste the file back into C:\windows\system32\drivers\etc\hosts – you will need administrator privileges for this.
STEP TWO: Visit your addon domain e.g. www.addondomain.com
Your computer should load the temp site instead of the actual live site, so now you can work off it. Note this is only for YOUR computer and can’t be accessed from other computers like previously done with your regular temp URL. Sucks, I know, but better than nothing.
Remember to edit the hosts file when you change your domain’s DNS.
Hope this helps!