修改window本地hosts文件,修改域名指向
如何修改hosts文件
# 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
在最后新增如下内容:
127.0.0.1 www.163.com
表示域名“www.163.com”指向的ip为127.0.0.1,即本地。修改后文件内容如下:
# 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
127.0.0.1 www.163.com
修改后用浏览器访问“www.163.com”会被解析到127.0.0.1,导致无法显示该网页。
为了进一步验证,使用tomcat在本地启动一个Web服务。tomcat版本为:apache-tomcat-8.5.4,其他版本应该操作类似。
下载解压tomcat后,运行apache-tomcat-8.5.4\bin\startup.bat,待tomcat启动成功,本地就有了一个Web服务了。
这时再访问"www.163.com:8080",就可以看到有页面内容了:
为什么要加上8080呢,因为这是端口号,tomcat开启的Web服务默认使用8080端口,而浏览器中默认的是80端口,所以必需要显示指明。也可以修改tomcat安装目录下的config/server.xml中的8080为80,这样就不用在访问时显式指定端口了。
这就是通过修改hosts文件来使域名指向某个IP的方式了,如果需要添加多条配置,直接再新增一行内容就行了。
修改window本地hosts文件,修改域名指向的更多相关文章
- 修改Window的hosts文件提示“该文件被其他程序占用”解决方案
1.打开C:\Windows\System32\drivers\etc中的hosts 2.右键——>属性——>安全 3.在修改保存就可以了
- 【计算机网络】windows修改本机hosts文件
hosts 文件所在的位置 C:/windows/system32/drivers/etc/hosts 修改后不必重启立即生效的方法 命令行下运行: ipconfig /displaydns 显示所有 ...
- 如何修改本地hosts文件?
1.window7修改本地hosts文件 # window7系统hosts文件位置 C:\Windows\System32\drivers\etc 2.linux # linux系统hosts文件位置 ...
- 修改容器的hosts文件
修改容器的hosts文件 1.介绍 docker容器中的hosts文件虽然在宿主机磁盘上/var/lib/docker/containers/xxx/hosts中,但是修改该文件是无效的,需要通过其他 ...
- k8s修改pod的hosts文件
1.在1.7版本后使用HostAliases修改pod的hosts文件.该文件由kubelet管理 在deployment的yaml文件中添加在pod template 的spec里面即可: apiV ...
- SUSE系列---修改IP和hosts文件
有些时候我们需要修改linux系统的IP,此时我们要注意,修改IP之后,如果我们如果不修改hosts文件,那么可能我们一些服务会无法使用:下面分别记录修改IP和hosts文件的方法: 修改IP: 打开 ...
- svn 从文件上次修改以来没有任何文件修改或加入。
现象:代码已经被修改过了,但是再往svn上提交代码时仍然提示: 从文件上次修改以来没有任何文件修改或加入. 解决办法: 1.找打存放代码的文件夹,右键——TortoiseSVN——clean up(清 ...
- Ubuntu16.04/windows7修改本地hosts文件
1. 从github上下载最新的hosts文件:https://serve.netsh.org/pub/ipv4-hosts/ ubuntu16.04: 第二步:Ctrl+Alt+T 打开ubuntu ...
- hosts文件修改之后立刻刷新
最近因为项目的需要,总是修改hosts文件,每次修改之后都要重启浏览器,总结下刷新的方式 window下,hosts文件位置:C:\windows\system32\drivers\etc\hosts ...
随机推荐
- [UE4]机器人射击逻辑行为树
1.寻找敌人 2.如果没有找到,等待2秒,跳转到1 3.如果找到了,走向敌人 4.走向敌人的过程中,如果看见敌人了,则射击 5.如果敌人没有了,则跳转到1
- 总结一下连日来在MAC下被Python3设下的坑
当时的情况:mac下自带python2, 1.安装pyhon3: 首次从官网下载了安装包安装,安装目录在/Library/Frameworks/Python.framework/Versions/3. ...
- MySQL常用语句大全
数据库操作:创建数据库create database database_name 查看数据库 show databases使用数据库use dbname删除数据库 drop database dbna ...
- URL传值乱码
JS端: &value=encodeURIComponent("value") C端: HttpUtility.UrlDecode(Request.Params[" ...
- react mobx webpack 使用案例
1.package.json: { "name": "wtest", "version": "1.0.0", " ...
- web端文字转语音的几种方案
最近在开发一个微信排队取号的的系统,其中对于服务员端(管理端) 需要有呼叫功能,即点按钮 就播出"xxx号顾客请就座"的声音. 经过在网上一番搜索研究,web端实现指定文字的语音播 ...
- Github上关于iOS的各种开源项目集合2(强烈建议大家收藏,查看,总有一款你需要)
资源list:Github上关于大数据的开源项目.论文等合集 Awesome Big Data A curated list of awesome big data frameworks, resou ...
- vue elment-ui 样式替换 input select
# 有时候经常需要替换element-ui的样式 第一种方法: 直接修改源码,样式路径如下 直接修改idnex.css即可. 第二种方法: 直接在当前页面修改,替换掉原来的样式. <style ...
- ViewPager的addOnPageChangeListener和setOnPageChangeListener的区别,ViewPager改变数据后IndexOutOfBoundsException
我的ViewPager数据改变后,在切换界面刷新数据时:OnPageChangeListener中的数据IndexOutOfBoundsException,我们来看源码探一下究竟: 代码时这样写的: ...
- Struts2学习:struts.xml引入自定义的xml文件
随着项目代码的增多,用一个struts.xml来管理所有功能模块的Action未免显得臃肿且结构不清晰,因此可以根据实际的功能划分,将各模块的Action放在自定义的xml文件中,再引入struts. ...