When doing web program development sometimes do such an operation, is to modify the Hosts file to do virtual domain name mapping to facilitate local development, For example, the www.jb51.net this domain point to the local 127.0.0.1, the operation itself is not complicated, but in the Windows environment, hosts file hidden deep, so we have to Baidu every time the Hosts file path and then a layer to open the file directory to find this file , if the change of frequent words, is really more trouble, so here I summed up a relatively good and slightly master a way to share.
First, use text editing software such as Notepad to write the following code:
Copy Code code as follows:
:: Remove the Hosts file read-only attribute
Attrib-r C:\windows\system32\drivers\etc\hosts
:: Edit Hosts file with Notepad
Notepad C:\windows\system32\drivers\etc\hosts
:: Add read-only attribute to Hosts file
attrib +r C:\windows\system32\drivers\etc\hosts
Then save the file as a. bat file with the suffix name (for example, Hosts.bat).
Second, put the file into the \Windows\System32 directory, in fact, this is not necessarily placed in this directory, you can create a new directory in any location, and then copy the full path of the directory to the WINDOWS system environment variables inside.
OK, a simple two-step, after the need to modify the hosts file, directly in the operation of the input hosts, the system will automatically turn the hosts file into a writable, and then open the Hosts file, waiting for editing after the exit and automatically turn the file into read-only. Very convenient