0

Let me introduce to the situation we had to face it and the core of the question.

We needed in our project to change the "localhost" to be something else like "newdomain-localhost.com", so we changed the hosts file (in Windows) and everything worked.

We reached the wall of Facebook with its sharer, where you need to get the site into a whitelist if you want to share content like flash. It's allright with the production server, but what happens in the dev enviroment?

My question is: if I change the hosts file to get localhost into something like "newdomain-localhost.com", when a request is thrown from my local machine to a service like Facebook, Facebook will take the domain "newdomain-localhost.com" or directly the public IP of my machine (which in this case is fixed, but it can be dynamic)?

Let me add that I think it perfectly makes sense to say that the hosts is something that affects locally, and the service receives the public IP instead of the domain name.

Correct?

4

3 回答 3

2

我不确定我是否理解你的问题,但我最好的猜测是它归结为:

如果我在主机文件中将 localhost 重命名为 newdomain.example.com,外部站点会看到吗?

答案很明确:

您的主机文件仅由您的本地机器用来解析地址 - 它对您本地机器之外的任何人/任何东西都不可见。现在,如果您将这些数据放在公共 DNS 中,那将是一个不同的故事 - 但我不会因为切线而使事情复杂化 * 钦佩切线 *

于 2010-09-09T22:01:55.410 回答
1

会发生以下情况:如果您向主机文件添加/更改某些内容(Linux 上的 /etc/hosts,Windows 上的 %windir%\system32\drivers\etc\hosts),则只有您的本地 PC 会有所不同,因为它首先看起来在此主机文件中,当它尝试查找主机名的 IP 地址时。主机名将与 HTTP 请求一起发送,因此 Web 服务器可以针对具有相同 IP 地址的不同主机名采取不同的操作。

您可能有兴趣阅读有关网络地址解析的信息(例如http://en.wikipedia.org/wiki/Domain_Name_System

于 2010-09-09T22:11:27.033 回答
0

你的项目到底在做什么?你在谈论Facebook连接吗?您所说的内容可以在您的计算机上正常运行 Facebook 连接,但只能在您修改了 hosts 文件的计算机上运行。

如果您设置了 Facebook 连接,因此您的应用程序转到http://www.production.com,那么您只需在主机文件中添加一行,说明 www.production.com 是 127.0.0.1。当您单击连接按钮时,登录窗口将打开,并将您重定向到 URL http://www.production.com以设置您的连接 cookie。由于您的计算机认为该站点的 IP 是 127.0.0.1,并且由于 cookie 是使用主机名而不是正常工作的 IP 存储的。

于 2010-09-09T22:10:22.933 回答