问题原文
原帖链接 · Burak TARHANLI · CC BY-SA 4.0
Today I bought a shared hosting package. Then I added an index.html to it via FTP. When I enter my given IP address in Chrome, I'm always seeing Plesk's default page, instead of my index.html. But then I edited my Windows's hosts file and entered a domain name next to the IP. When I entered that domain name in Chrome, I saw my index.html file correctly.
So my question is, why can't I see my index.html via requesting directly with my IP address?
已采纳解答
原帖链接 · Burak TARHANLI · CC BY-SA 4.0
I think I found my answer.
So, the thing is, because I bought a shared hosting package, they also gave me a shared IP. My guess is, this IP has many websites next to mine and they're all accessible with this same shared IP address.
The trick is the HTTP GET request's Host header!
When I entered the shared IP directly in the address bar, the Host header is the same as the shared IP address. So the host doesn't know which shared website to display as a response.
And when I edited Windows's Hosts file and then examined the HTTP GET request, I saw that the Host header is set to my domain name, even though I requested the same shared IP! So this time, the host knows which website that this request belongs to!
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
