New station test skillfully use system Hosts file

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Statement, the following www.xxx.com XXX on behalf of your domain name (I do not have the capital to buy this advanced domain name), is not suspected of advertising behavior.

For hyperlinks, SEO optimization is recommended unified use of http://www.xxx.com format, that is, the weight on the WWW, but if only to buy domain names, there is no purchase space, or even the domain name has not been purchased, then whether only/root directory representation can not use the domain name, First of all, the disadvantage of the usual methods: hyperlinks used/to represent the root directory, or relative path, then for SEO optimization to be modified for http:// www.xxx.com format, you need to replace each, so if the hyperlink is very dispersed, it is not very hard, but also may be careless because of a lot of, of course, you can use. htaccess, but why not use http://directly in writing code Www.xxx.com, this is because we usually use http://www.xxx.com cannot point to the root directory, so now we solve this problem, just modify the hosts file to achieve the purpose, just add the following code in the Hosts file (with Notepad to open, If you are using WINDOWS XP, then the Hosts file is in C:/windows/system32/drivers/etc:

127.0.0.1 www.xxx.com

No need to add a note to match the #, which is as follows

#127.0.0.1 www.xxx.com

Use the time to Zhus comments to be removed on the line.

This access www.xxx.com is actually access to 127.0.0.1, and access 127.0.0.1 is access to your root directory, style you can also use the www.xxx.com format, such as: href= "http://www.xxx.com/css/ Xxx.css "(Other parts of the Code to supplement themselves), so that the normal display of the call style, not disorderly, I personally tested feasible, so rest assured use.

The same hyperlink or picture and so on can use the http://www.xxx.com format, the link is the local location. Even if you actually have a server that uses this domain name, you can use the local root directory for the "wall" outside. Why the hosts so magical, this is because when users enter the Web site in the browser and then execute, the system will first look for the hosts file to find the corresponding IP address, if not find the setting in the hosts, then will be the URL to submit DNS resolution, and then access that IP, So we set the IP in the hosts to have priority. In this way, even if the domain name is not sold, we can conduct crazy tests.

If you like me, often use this method of testing, that is, to constantly modify the hosts file, then each time to the Hosts file location, which is also the trouble, if you use Python, the following code is useful to solve this problem:

Import OS

Start_directory = "C:/windows/system32/drivers/etc"

Os.startfile (Start_directory)

Copy the above code to Notepad, then rename it to hosts.py, and then just double-click the hosts.py to jump to where we want to jump, where the Hosts file is located: c:/windows/system32/drivers/etc

Similarly, you can write a py file to jump to our computer's own structure of the server root directory location.

Article Source: Ol House (www.olzhijia.com), reprint please keep the link.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.