windows设置通过主机名访问网站

在日常开发过程中,我们经常需要通过主机名直接访问网站,其实设置很简单,一共分为2步。

Step1 打开hosts文件

用记事本或者Nodepad++打开,路径为C:\Windows\System32\drivers\etc\hosts

Step2 修改配置文件,将ip和主机名添加到下方

# 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

# 这里增加对应的ip和主机名
192.168.1.100 hadoop100
192.168.1.101 hadoop101
192.168.1.102 hadoop102
192.168.1.103 hadoop103
192.168.1.104 hadoop104

保存退出后,就可以直接通过主机名进行访问了,比如hadoop100,就直接访问192.168.1.100这个ip。

你可能感兴趣的:(windows)