大网数据广告活动
网站运营与故障问答

IP ADDRESS request vs. DOMAIN NAME request?

· 52CE 我爱测

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…

问题原文

原帖链接 · 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!

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2020-01-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。