2008年2月23日 星期六

設定hosts 來指定測試網址

你可以在瀏覽器中輸入http://localhost,這其實等同你輸入http://127.0.0.1,為什麼會這樣呢?原因就在於在hosts中有描述localhost的domain name其實是要對應到127.0.0.1這個IP的,所以若你想要將某個domain name對應到自己的測試環境,只要去修改這個設定檔就可以了,而不需要去動到整個網路環境。

這個檔案的位置在 C:\WINDOWS\system32\drivers\etc\hosts

因為我很懶, 所設一個很短的Domname test.tw

# Copyright (c) 1993-1999 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

127.0.0.1 localhost
127.0.0.1 test.tw

【下列文章您可能也有興趣】

沒有留言: