HOSTS binds the domain name and IP address, but the access IP address and domain name have different content.

Source: Internet
Author: User
HOSTS is bound to the domain name and IP address, but the access IP address and domain name are different. the HOSTS file is bound in this way.
119.57.113.31 cloudtest.cnfol.com

The access IP address displays such content.


This is the result of the output domain name.



In this way, enter the domain name. The operating system will first find the HOSTS file and map it to an IP address.

Therefore, the access IP address and domain name should be the same result.

GOOGLE. no answer is found !!

A host may have multiple websites, so the IP address may not be accessible and the domain name can be accessed. I understand this.

The key is to bind it to the HOSTS. I cannot figure it out.

Please explain !!!


Reply to discussion (solution)

If you bind an ip address to multiple domain names, which domain name should you use to access the ip address?

When you access the ip address, it is equivalent to accessing localhost on the local machine. by default, it points to the DocumentRoot in your apache, instead of your domain name.

In this way, enter the domain name. The operating system will first find the HOSTS file and map it to an IP address.
You understand that.

Therefore, the access IP address and domain name should be the same result.
It is almost equivalent, but there are exceptions, that is, the two are completely different when configuring apache.

ServerAdmin ??? @ Gmail.com
DocumentRoot "D:/wamp/www/_ get.tw"
ServerName 7.7di.net



ServerAdmin ??? @ Gmail.com
DocumentRoot "D:/wamp/www/_ web.tw"
ServerName 7di.net

This is two different websites on the same server. although the two websites point to the same ip address, they are used to open different websites.

The key to the problem is how you configure the cloudtest.cnfol.com host.

The key to the problem is how you configure the cloudtest.cnfol.com host.

It can be said that through HOSTS, we all use IP addresses to access the server. Therefore, the server returns the same result.

I guess, is it like this? the input in the address bar is sent to the server before the server can determine which one is returned to us?

Therefore, if the domain name server is not configured, you must bind it to the HOSTS file.

If you use an ip address or a domain name to access different pages, they do not enter the same portal file.
Of course, it is not ruled out that you have checked the entry file, but it is absolutely your problem.
If multiple websites can be accessed through the same ip address, the domain name bound to the virtual host must be set.
When the web host and the virtual host coexist, the web host domain name (localhost) must be bound to the virtual host list at the same time.
The hosts file is only a tool to replace dns. all domain names in it no longer query the ip address from dns.
However, the ip address is only used for network connection, and the web server's response is based on the domain name.

Related Article

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.