As a web developer, deployed in the local application, we have unlimited familiarity with the localhost, but also infinite helplessness. In any case, different applications are labeled LOCALHOST:XXXX address, as if the web should have a character, only John, Dick such a salutation. In many cases, we may want to have a more personalized URL to represent different applications, then there is no domain name or do not want to bother DNS resolution, so the deployment of local should, there is a nice URL is a good idea. Well, let's try it.
The main work consists of two basic simple steps:
Configuring native Host
Configuring website in IIS
Configuring the host service for this computer
By default, the host file is located in the%systemroot%\system32\drivers\etc\ directory and can only be edited as an administrator. Open "Notepad" with "Run as Administrator" and open the host file to the specified directory as follows:
# Copyright (c) 1993-2009 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 host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
Special reminder, before modifying the host file, it is best to make a backup of the original file.
Then we can configure the desired domain name, for example:
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 dev.anytao.net
127.0.0.2 prj.anytao.net
127.0.0.3 lab.anytao.net
All of these configurations are valid, which means that in the native environment, The IP address of the 127.0.0.3 can be accessed through the lab.anytao.net, and the 127.0.0.1 address can be accessed through localhost or dev.anytao.net, although 127.0.0.1 is usually localhost by default, so we should try to avoid This configuration.