The path of the hosts file is "C:\Windows\System32\drivers\etc". Hosts is a system file without an extension. Its function is to establish an associated "database" between some commonly used URL domain names and their corresponding IP addresses. When the user enters a URL that needs to be logged in in the browser, the system will first automatically start from Find the corresponding IP address in the Hosts file and open the corresponding web page; if not found, the system will submit the URL to the DNS domain name resolution server for IP address resolution.
The operating environment of this tutorial: Windows 7 system, Dell G3 computer.
Hosts is a system file without extension, which can be opened with Notepad and other tools. Its function is to establish an associated "database" between some commonly used URL domain names and their corresponding IP addresses. When the user opens the browser When you enter a URL that needs to be logged in, the system will first automatically search for the corresponding IP address in the Hosts file. Once found, the system will immediately open the corresponding web page. If not found, the system will submit the URL to the DNS domain name resolution server for IP Address resolution.
It should be noted that the mapping configured in the Hosts file is static. If the computer on the network changes, please update the IP address in time, otherwise you will not be able to access it.
Working Principle
When a browser accesses a website, it must first resolve the domain name of the website to be accessed into its designated IP address through the DNS server. After that, the browser can Locate this website and access its data.
The operating system stipulates that before making a DNS request, first check whether there is a mapping relationship between the domain name and IP in your own Hosts file. If there is, then directly access the network location specified by this IP address. If not, then make a domain name resolution request to a known DNS server. In other words, the IP resolution priority of Hosts is higher than that of DNS.
The storage location under windows
The location of the hosts file is different in different operating systems (or even different Windows versions). The address under windows is :
C:\Windows\System32\drivers\etc
##Opening method:
##Windows version original host file content:
# 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
If you suspect that your hosts file has been modified by a virus or Trojan, you can copy the above content to repair the hosts file.
It is worth mentioning that # is followed by comments, so clearing the hosts file has no impact on the normal operation of the system.
The role of Hosts file1. Speed ??up domain name resolution
For websites that we want to visit frequently, we can configure the domain name and IP in Hosts Mapping relationship to improve domain name resolution speed. Due to the mapping relationship, when we enter the domain name, the computer can quickly resolve the IP without requesting the DNS server on the network.
2. Convenient for LAN users
In the LAN of many units, there will be servers available for users to use. However, since DNS servers are rarely set up in local area networks, when accessing these servers, you have to enter IP addresses that are difficult to remember. This is quite troublesome for many people. You can give these servers names that are easy to remember, and then establish IP mapping in Hosts, so that when you visit in the future, you only need to enter the name of the server.
3. Block websites (domain name redirection)
There are many websites that install various plug-ins into your computer without the user’s consent. Some of them may be Trojan horses or Virus. For these websites, we can use Hosts to map the domain name of the website to the wrong IP or the IP of the local computer, so that there is no need to access it. In the WINDOWS system, it is agreed that 127.0.0.1 is the IP address of the local computer, and 0.0.0.0 is the wrong IP address.
If we write the following content in Hosts:
127.0.0.1要屏蔽的網(wǎng)站A的域名 0.0.0.0要屏蔽的網(wǎng)站B的域名
In this way, when the computer resolves domain names A and B, it will resolve to the local IP or the wrong IP, thus blocking the website The purpose of A and B.
4. Smooth connection to the system
For Lotus servers and some database servers, if you directly enter the IP address during access, you cannot access it. You can only access it by entering the server name. Then we configure the Hosts file so that we can connect smoothly by entering the server name.
5. Virtual domain name
Many times, website builders need to build the "soft environment" before uploading and debugging. But similar to the mail service, you need to use a domain name to assist debugging. In this case, you can point the local IP address to a "virtual domain name" to achieve the required effect without any cost. For example:
127.0.0.1 網(wǎng)站域名
and then enter the corresponding website domain name in the browser address bar.
For more related knowledge, please visit the
FAQThe above is the detailed content of What is the path to the windows hosts file. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

TosetupdualmonitorsonWindows,firstcheckhardwarecompatibilitybyensuringyourGPUhasmultiplevideoportsandyouhavethecorrectcables;connectthesecondmonitor,poweronbothdisplays,andletWindowsdetectthemautomatically;thenopenDisplaysettings,identifyandarrangeth

CheckPHPinstallationbyrunningphp-vinCommandPromptandensurePHPisinPATH.2.DownloadtheComposer-Setup.exeinstallerfromgetcomposer.org,runit,followthewizard,andallowsystem-wideinstallation.3.Verifyinstallationbyrunningcomposer--versioninanewCommandPromptt

To create a bootable Windows USB drive, you need to select the right tools and mirror files and follow the steps. 1. Prepare 8GB or more USB drives, networked computers, official ISO files and production tools such as MediaCreationTool or Rufus; 2. Use MediaCreationTool to quickly create the latest system installation disk. It takes about 10 to 20 minutes to write to the USB drive after selecting the corresponding language and version; 3. Rufus provides more customization options, supports loading any ISO files and selecting partition plans; 4. After the production is completed, you need to enter the BIOS/UEFI setting to turn off SecureBoot, adjust the startup sequence, and confirm the startup using the USB drive; the parameters need to be carefully selected throughout the process to ensure installation

First run the power troubleshooter, then use the administrator command prompt to execute the powercfg-restoredefaultschemes command to reset the power scheme, then update or reinstall the ACPI driver, check the Group Policy settings (Pro/Enterprise Edition only), run sfc/scannow to repair the system files, and determine whether it is a user profile problem by creating a new user account. In most cases, the power options will return to normal.

Night mode cannot adjust the color temperature or does not take effect, which is usually caused by system settings or driving problems. First check whether night mode is actually enabled: go to Settings > System > Display, confirm that the "Night Mode" switch is on. If the gray is not selected, it may be a problem with the graphics card driver or system version; secondly, if the color temperature adjustment is invalid, you can try restarting the Explorer, use the registry to repair, reset the night mode settings, and turn off the conflicting third-party software; finally check the time and geographic location permissions: Ensure that the location is allowed in the privacy settings, and enable the automatic time and time zone setting function.

The key to installing Windows to RAID arrays is to correctly prepare the driver and set up BIOS/RAID. 1. Download and prepare the corresponding model of RAID controller driver in advance to ensure that it matches the Windows version and system bit count; 2. Set SATA mode to RAID in BIOS and create an array through the RAID tool to ensure that the status is normal; 3. Import the RAID driver through the "Load Drive" function during the installation process, so that the installer can identify the array; 4. After installation, the motherboard chipset driver needs to be installed, check the array status regularly, and use manufacturer tools to monitor performance to avoid replacing the hard disk at will. Do these steps and the RAID installation will be completed smoothly.

Gotohttps://code.visualstudio.comanddownloadtheWindowsUserInstaller.2.Runthe.exefile,allowchanges,andselectrecommendedoptionsincludingaddingtoPATHandcreatingadesktopshortcut.3.ClickFinishtolaunchVSCodeafterinstallation.4.Optionallyinstallusefulextens

When the prompt "Windowscannotfind the Microsoft Software LicenseTerms" appears, the main reason is that the system cannot find the license agreement file. The solution is as follows: 1. Check whether the installation media is complete, use official tools to remake the boot USB flash drive and verify the ISO hash value; 2. Manually add the license agreement file, copy license.rtf from a normally running Windows computer to the installation media and ensure that the version matches; 3. Change the BIOS settings, try to switch the startup mode or turn off the SecureBoot function; 4. Avoid using a third-party streamlined system, it is recommended to use the standard ISO image provided by Microsoft's official website to avoid component missing problems