windows 修改hosts檔案方法

來源:互聯網
上載者:User

看慣了http://localhost在本地測試的網域名稱,想換種寫法行不行,比如說想變成http://www.111cn.net,但網頁訪問仍然是原來http://localhost的內容,如何做到呢?

可以修改原生一個檔案來實現。

在系統硬碟中的如下路徑

 代碼如下 複製代碼

C:WINDOWSsystem32driversetc

找到“hosts”檔案,右鍵開啟檔案選擇文字檔方式,可以看到如下內容:

 代碼如下 複製代碼

# 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 localhost

大家知道怎麼做了吧?

就是在這行下添加新行,將localhost修改為想要的網域名稱,如下

127.0.0.1 www.111cn.net

需要注意的是,“127.0.0.1”和“www.111cn.net”之間用Tab鍵間隔開

想添加什麼網域名稱就接著往下加好了,就這麼簡單。

添加完成後就儲存,然後就可以用www.111cn.net訪問自己本地的網站了。

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.