What is the path to the windows hosts file
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要屏蔽的网站A的域名 0.0.0.0要屏蔽的网站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 网站域名
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

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

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

Undress AI Tool
Undress images for free

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



Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

Pull vertical guides in Photoshop: Enable ruler view (View > ruler). Hover the mouse over the vertical edge of the ruler, and then the cursor becomes a vertical line with double arrows and hold and drag the mouse to pull out the reference line. Click Delete by dragging the guide, or hovering it into a cross.

The MySQL connection may be due to the following reasons: MySQL service is not started, the firewall intercepts the connection, the port number is incorrect, the user name or password is incorrect, the listening address in my.cnf is improperly configured, etc. The troubleshooting steps include: 1. Check whether the MySQL service is running; 2. Adjust the firewall settings to allow MySQL to listen to port 3306; 3. Confirm that the port number is consistent with the actual port number; 4. Check whether the user name and password are correct; 5. Make sure the bind-address settings in my.cnf are correct.

Unable to access MySQL from the terminal may be due to: MySQL service not running; connection command error; insufficient permissions; firewall blocks connection; MySQL configuration file error.

The solution to MySQL installation error is: 1. Carefully check the system environment to ensure that the MySQL dependency library requirements are met. Different operating systems and version requirements are different; 2. Carefully read the error message and take corresponding measures according to prompts (such as missing library files or insufficient permissions), such as installing dependencies or using sudo commands; 3. If necessary, try to install the source code and carefully check the compilation log, but this requires a certain amount of Linux knowledge and experience. The key to ultimately solving the problem is to carefully check the system environment and error information, and refer to the official documents.

The main reasons for MySQL installation failure are: 1. Permission issues, you need to run as an administrator or use the sudo command; 2. Dependencies are missing, and you need to install relevant development packages; 3. Port conflicts, you need to close the program that occupies port 3306 or modify the configuration file; 4. The installation package is corrupt, you need to download and verify the integrity; 5. The environment variable is incorrectly configured, and the environment variables must be correctly configured according to the operating system. Solve these problems and carefully check each step to successfully install MySQL.

The secrets to mastering Office software include: understanding different versions and platforms, correctly installing and configuring, proficient in using the software interface, in-depth understanding of feature operations, application collaboration and sharing functions, utilizing templates and styles, mastering advanced skills, and solving common problems. In addition, you need to choose a version that suits your needs, make good use of templates and styles, develop backup habits, and learn shortcut keys and advanced techniques to improve efficiency.