Hosts 檔案是本機 DNS 解析的優先查詢表,系統解析網域時優先讀取此檔。善用 Hosts 可封鎖惡意/廣告網域、加速常用網站存取、測試開發環境網域對應。本文教您定位、編輯、生效 Hosts 檔案。
C:\Windows\System32\drivers\etc\hosts(無副檔名,純文字檔)
notepad → Ctrl + Shift + Enter)。C:\Windows\System32\drivers\etc → 右下角「文字文件」改為「所有檔案」→ 選取 hosts。

IP位址 網域名稱 #註解127.0.0.1 ads.example.com #封鎖廣告伺服器192.168.1.100 dev.local #本地開發環境# 127.0.0.1 localhost #井號開頭為註解,不生效

ipconfig /flushdns 清除 DNS 快取,即時生效。::1 對應規則。掌握 Hosts 編輯技巧,讓您擁有本機級的網域導向控制權,安全、開發、加速一檔搞定。