Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7系統Hosts檔案位置與修復完整教學

編輯:Win7 系統應用技巧

Hosts 檔案是無副檔名的系統文字檔,負責將網域名稱對應到指定 IP 位址,常用於加速網頁存取、封鎖惡意網站或本地開發測試。本文說明 Win7 下 Hosts 的預設位置、功能原理,以及損毀後的標準修復步驟。

Hosts 檔案位置

統一路徑:C:\Windows\System32\drivers\etc\hosts

快速開啟方式:按 Win+R → 輸入 C:\Windows\System32\drivers\etc → 找到 hosts 檔案。

Hosts檔案示意
Hosts功能說明
檔案路徑
執行開啟路徑

Hosts 運作原理

瀏覽器解析網址時,優先查詢 Hosts 檔案。若找到對應 IP,直接連線;否則轉向 DNS 伺服器解析。正確設定可大幅提升特定網站存取速度。

標準修復步驟(恢復微軟預設內容)

  1. 將 hosts 複製到桌面備份,用記事本開啟。
  2. 刪除所有內容,貼上以下預設內容並儲存:
# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# ...
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
  1. 將修改後的檔案覆蓋回 C:\Windows\System32\drivers\etc(需管理員權限)。

記事本編輯
預設內容
覆蓋回原位置

注意:修改 Hosts 需管理員權限,建議先備份原檔。若常需編輯,可建立桌面捷徑指向該檔案,以管理員身分開啟記事本編輯更便利。

Copyright © Windows教程網 All Rights Reserved