Anytao.net |. NET website you must know|Anytao technology blog
Released on: 2009.11.27 by: Anytao
2009 original works of Anytao.com and Anytao. Please refer to the author and source in the post.
As Web developers, we are all familiar with localhost and have unlimited helplessness when deploying applications locally. In any case, different applications are given the address localhost: XXXX. It seems that the Web with a personality should only be called by James and James. In many cases, we may want to have a more personalized url to represent different applications. If there is no domain name or we don't want to bother with DNS resolution, we should deploy it locally, it is a good idea to have a nice url. Then, let's try it.
The main work includes two basic simple steps:
- Configure local Host
- Configure WebSite in IIS
Configure the local Host service
By default, the Host file is located in the % systemroot % \ system32 \ drivers \ etc \ directory and can only be edited as an administrator. Take"Run as Administrator"Open"Notepad", And open the Host file in the specified directory, as shown below:
# 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 shoshould be kept on an individual line. The IP address shold
# Be placed in the first column followed by the corresponding host name.
# The IP address and the host name shocould 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
Note: We recommend that you back up the original file before modifying the Host 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
The above configuration is valid, which means that in the local environment, you can access the IP address 127.0.0.3 through lab.anytao.net and access the 127.0.0.1 address through localhost or dev.anytao.net, 127.0.0.1 is set to localhost by default. Therefore, we should try to avoid this configuration.
Configure your WebSite in IIS
With available domain names, you will be familiar with the rest of the work. We simply recall that when deploying an application on the local machine, we set different ports when adding an application to distinguish different applications. For example:
- Http: // localhost: 1234/
- Http: // localhost: 5678/
Now, everything becomes simple. You only need to specify the IP address you configured in the Host when binding the IP address. For example, if I want to publish an application about lab.anytao.net, I can configure it like this:
Now, type lab.anytao.net in the browser to open the locally deployed application. The previous 127.0.0.1 or localhost disappears. Looking at anytao.net, I feel comfortable. A little trick can bring a lot of GAINS. By configuring the host in the development phase, you can directly access the local site with your project domain name. This is really great.
In fact, this is all very simple. It is better to let the beautiful Code put on a beautiful coat and fly on the address of the browser?
For more gossip, follow anytao.net
Anytao | 2009 Anytao.com
2009/11/27 | http://anytao.cnblogs.com/| http://anytao.net/blog/post/2009/11/26/anytao-devstory-12-running-your-app-with-your-domain.aspx
This document is provided as "the status quo" without any guarantee and does not grant any rights. | This posting is provided "as is" with no warranties, and confers no rights.
The copyright of this article is owned by the author. You are welcome to repost this article, but you must keep this statement without the author's consent and provide a clear link to the original article on the article page. Otherwise, you will be entitled to pursue legal liability.