Handy trick for setting up new website

Status
Not open for further replies.
hi all -

suppose you are working on a new website, but one of the following conditions exist (as it always does)

1) you just purchased the name and are waiting for it to propagate
2) you are migrating a website to a new server but you really should test it first

on windows, look for this file:

C:\Windows\System32\drivers\etc\hosts

simply go into this file with your favorite editor (like notepad), and enter your IP number and domain name. for example, I might enter:

69.10.48.25 MarksLameWebsite.com
69.10.48.25 www.MarksLameWebsite.com

then, on my computer (and ONLY on my computer), http://MarksLameWebsite.com appears to be a live website!

NOTE - dont forget to remove this entry from your hosts file!
 

Wiseword

New Member
Thanks for sharing, it's a nice trick and can come in handy. Anyway, I am pretty new to this hosting things, so sorry for my stupid question. Would the trick work no matter wherever you put your website files on your computer?
 

Quags

Administrator
Staff member
This is a great suggestion. What this does is "tricks" your computer into thinking a domain name points to a particular ip. The above example is for windows, but the same can be done on linux by editing /etc/hosts. I believe MacOS also uses /etc/hosts.

I use this for testing websites before an IP change over is done, or during dns propagation where I can not see the domain name on the new IP.

Generally using this trick your website files are on a remote system, just the domain name is not pointing to that IP. It would be possible to use 127.0.0.1 to point a domain to your own computer/system but a webserver is required.
 
Would the trick work no matter wherever you put your website files on your computer?
this trick merely overrides the name server settings that one might set up with 1and1.com, register.com (or godaddy, but we dont like godaddy ;) so if your domain registry setting works, this will work. your website files still have to be in the correct place in order to be recognized as a website.


NOTE: most servers have another trick to test websites, where you use some rather long and involved URL rather than the nice short one.

it might look something like:
http://myOfficialDomainName.com/~home/test/test/more-test/myNewDomainName.com/

this string might be created and set by your control-panel but i am not sure. John, do you know?
 

Quags

Administrator
Staff member
On our shared hosting the temporary url is http://server-name/~yourusername/ which is offered via our webserver by a module called mod_userdir (we use apache). It may not be available on all servers with out manually enabling it. cPanel/WHM will have it by default, unless it is disabled on mod_userdir tweak in the Web Host Manager.
 

Minion

New Member
So, is this trick more like a "back way" of getting into your site? It makes sense, and I can see why it would only work on the same IP.
 
hey minion - you can always get into your site via the control panel (and ftp), assuming you either:
1) paid your bill
2) were extra-nice to Quags.

this trick would probably work if for some reason you lost your domain name, but by then the website is a lost cause!
 

Violescent

New Member
This is a great tip! It would certainly help you to get a jump-start on getting your site up and running. I hate waiting when I am anxious to get started!
 

rdxblast

New Member
This is a fantastic recommendation. What this does is "tricks" your pc into considering a sector address factors to a particular ip. The above example is for windows, but the same can be done on linux system by modifying /etc/hosts. I believe MacOS also uses /etc/hosts.

I use this for examining sites before an IP modify over is done, or during dns reproduction where I can not see the sector address on the new IP.

Generally using this technique your web page information are on a distant program, just the sector address is not directing to that IP. It would be possible to use 127.0.0.1 to factor a sector to your own computer/system but a webserver is needed.
 

bearbin

New Member
/etc/hosts is the same for Linux and other *nixes. It's a remnant from before DNS and your computer always looks there first for hosts before checking DNS.
 

rcg2222

New Member
The HOSTS file is great for stuff like this. It's also wonderful for blocking things like Facebook and Reddit when I'm trying to program, haha.
 

n25an

New Member
I knew the 127.0.0.1 trick but the other one you suggested at the very top is something I did not know...
 

NatureSun

New Member
Wow! This is quite a nifty trick!

I will make sure to use this the next time I'm making a website it will be quite useful. I never even knew this was possible, haha!

Cheers!
 

nonsiccus

New Member
Also, if you're working on it locally like this on a WAMP or something, you can even get access to the site from the WAN if you configure a reverse proxy to forward requests to the correct WAMP instance. This is a fairly involved process, so I definitely recommend looking up a guide for your particular set up.
 

Quags

Administrator
Staff member
Thanks for all the comments. Since this is a tutorial and the hosts file change is covered I am closing this thread.

</thead>
 
Status
Not open for further replies.
Top