SOLVED: How to access your site’s temporary URL for addon domains

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.

A standard file structure for an addon domain (on Linux servers at least)
A standard file structure for an addon domain (on Linux servers at least)

 

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.

  1. On your computer, go to C:\windows\system32\drivers\etc\hosts
  2. Copy the file to Desktop or some other folder.
  3. 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
  4. Save the file – be careful not to add a suffix e.g. hosts.txt, save it just as “hosts”.
  5. 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!

Picture of Michael

Michael

Leave a Reply

Your email address will not be published. Required fields are marked *

About Me

I run Pixl.my, a managed hosting service in Kuala Lumpur, Malaysia.

This is a place for me to pen my thoughts.

Recent Posts