Local domain || set up of local site
by Arxleol on Monday 04.05.2009, under Programming, tutorial, windows
In this article I will explain how I solved problem I had for ages like. As I am writing many web sites well, scripting doing it for fun job and so on. I often found myself in difficult when I wanted to check the site locally but I had to use either localhost or 127.0.0.1 ip address. So if you are working on certain project and you are doing it locally on your machine. I mean that you have server locally running.
OK I read the first paragraph and even I don’t understand it. Dismiss that!
What I wanted to say when I work I like to have the same or almost the same environment in developing stages as it will be used in the final product, when its uploaded to some remote server and/or such things.
So what I wanted was to have way when I enter name of site in my browser it in fact connects to local machine/server and not to some remote server.
If you have similar problem solution to it is very simple moreover trivial. If you are using Windows OS, I honestly haven’t searched about this topic and don’t know how to do it in Linux.
The point is to traverse yourself to the following directory in the system. It should in fact be the same as here except maybe partition used:
C:\Windows\System32\drivers\etc
there you will find file named hosts open it with any text editor I suggest using notepad since it will work hundred percent, since some other text editors have different new line encoding and there might occur problems. Especially for those origination on *nix platforms.
So if you open this file its contents should be similar to the following:
# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host127.0.0.1 localhost
Now what should you do is simple and maybe you already know what to do.
Let’s say that our website is test.com what you would do is simple just after the line where localhost is written add new line:
127.0.0.1 test.com
You also have to restart your browser and after that when you write in URL line test.com it will reroute you to the localhost or more correctly to the ip address 127.0.0.1 which is address of your local server.
Problems that might occur is that you haven’t inputted correctly something, remember in between 127.0.0.1 and test.com is tabulator, otherwise it doesn’t work. Also I have noticed few times that it doesn’t read this file properly if there is one additional enter after the last line. However not always, and this completely eludes me why does this happen.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=c4e2d46b-a355-4ce0-b334-112106816bca)
Tuesday 02.06.2009 on 15:49
Hi, good post. I have been wondering about this issue,so thanks for posting. I’ll definitely be coming back to your site.
Wednesday 06.01.2010 on 02:14
pleasure is all mine,
ax
Thursday 27.05.2010 on 22:51
[...] is to change dns records again on your local machine. If you don’t know how to do it check this tutorial. You need to add this value in hosts file and save file: 127.0.0.1 [...]