共享主机、域名和 DNS 如何协同工作?

发布于 2024-09-01 03:25:00 字数 383 浏览 1 评论 0原文

我有一点疑问,但我找不到有关它的信息,可能是因为我没有搜索正确的东西。

当浏览器请求“www.mydomain.com”时,DNS 服务器会返回一个 IP 地址,然后浏览器会前往该地址...但是接下来会发生什么呢?我的意思是,该 IP 地址可能是包含数百个网页和域的共享主机,那么它如何知道它必须去哪里?

是网络服务器做的事情吗?我可以在网络应用程序中实现它吗?

我的意思是,例如我有一个包含帐户的 Web 应用程序,每个帐户都有一个默认网页。您可以通过帐户名称访问该页面,例如“www.mydomain.com/myaccount”,但现在我想注册“www.myaccount.com”,然后它将获得“www.mydomain.com/myaccount”内容。是否可以?

亲切的问候。

I 've this little doubt but I couldn't find information about it, probably because I'm not searching the correct thing.

When a browser ask for "www.mydomain.com", the DNS server returns an IP Address, then the browser go there... but what does happen then? I mean, that IP address could be a shared hosting that contains hundreds of web pages and domains, so how does it knows where it have to go?

Is something that the web server does? is it something that I could implement in a web application?

I mean, for example I have a web application that contains accounts, and each account has a default web page. You could access that page passing the account namne, for example "www.mydomain.com/myaccount", but now I want to register "www.myaccount.com" and then it will get the "www.mydomain.com/myaccount" content. Is it possible?

Kind regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流年里的时光 2024-09-08 03:25:00

HTTP/1.1 要求所有请求都包含 Host 标头其中包括您输入的域名。因此,对“http://www.example 的基本请求.com/foo/bar.html”将如下所示:

GET /foo/bar.html HTTP/1.1
主机:www.example.com

然后,Web 服务器将能够使用 Host 标头将请求路由到正确的网站,即使同一 IP 地址上有多个网站也是如此。

HTTP/1.1 requires that all requests include a Host header which includes the domain name that you typed in. So a basic request for "http://www.example.com/foo/bar.html" will look like this:

GET /foo/bar.html HTTP/1.1
Host: www.example.com

And the web server will then be able to use the Host header to route the request to the correct website, even if there's more than one on the same IP address.

⊕婉儿 2024-09-08 03:25:00

网络服务器负责处理哪个应用程序响应您的请求。您的“共享主机”还有另一个名字。它被称为“虚拟主机”。网络服务器有一个“虚拟主机”列表,根据您访问主机的方式(通过主机名),网络服务器选择哪个应用程序响应您的请求。

The webserver handles which application responds to your request. Your "shared hosting" has another name. It's called "virtual hosts". The webserver has a list of "virtual hosts" and depending on how you got to the host (via what hostname), the web server picks which application responds to your request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文