如何确认用户拥有像 Google Analytics 这样的网站?
我想为用户实现一个脚本,以确认某个网站归他们所有(或者至少他们可以控制该网站),就像 Google Analytics 的做法一样。这样做最安全的方法是什么?我知道 Google Analytics 要求您将脚本上传到网站的根目录,但是还有其他方法吗?另外,谷歌分析是如何实现这一目标的?
I want to implement a script for users to confirm that a website is owned by them (or at least they have control over it) like how Google Analytics does it. What is the most secure way of doing this? I know Google Analytics require you to upload a script to your site's root directory, but are there other ways of doing it? Also, how does Google Analytics accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google Analytics 不要求您将任何内容上传到根目录,也不要求您拥有自己的域。 (它确实提供了一项可选的验证服务,它会尝试告诉您是否已将 Google Analytics(分析)代码段添加到您的网页中。)
Google Analytics(分析)接受对特定帐户的任何点击,但不接受验证谁拥有哪个网站。 (如果有人获取您的 Google Analytics(分析)代码段(包括帐号)并在自己的网站上使用它,这很少会导致问题,但这些数据很容易被过滤掉。)
一些工具,例如 Google 网站管理员工具,要求您证明您拥有一个网站。
验证域所有权的两种最常见的方法是:
在这两种情况下,服务都会检查是否已进行更改,通常允许用户启动验证检查(在完成步骤后)。据推测,可以通过使用类似
curl
的方式来查看文件是否存在,和/或通过 ping 域的 DNS 来查看记录是否存在。编辑:
所以,第一个的常见方法是指示他们创建一个具有特定名称和特定内容的文件。因此,假设您告诉他们创建一个名为
bz239239239.html
的页面,并告诉他们该文件应包含文本checkbz239239239
。然后,为了验证他们是否遵循了您的指示,(PHP 示例)
我不是 DNS 专家,但我的理解是 DNS 被认为与网站本身一样安全。即,您可以假设它是安全的,但理论上它有可能被黑客攻击,但到那时,整个网站本身就会受到损害,这是他们的问题,而不是您的问题。
Google Analytics does not require that you upload anything to your root directory, nor does it require that you own your domain. (It does provide an optional validation service, where it will try to tell you if you've added the Google Analytics snippet to your pages.)
Google Analytics accepts any hits to a particular account, and doesn't validate who owns what site. (This can rarely cause problems if someone grabs your Google Analytics snippet, account number included, and uses it on their own site, but that data can easily be filtered out.)
Some tools, like Google Webmaster Tools, require that you certify that you own a website.
The two most common ways of certifying ownership of a domain are:
In both cases, the services checks if the change has been made, usually allowing the user to initiate the validation check (after they've completed the steps). Presumably, by using something like
curl
to see if the file exists, and/pr by pinging the domain's DNS to see if the record exists.EDIT:
So, the common method of doing number one is to instruct them to create a file with a particular name and particular contents. So, let's say you tell them to create a page called
bz239239239.html
, and tell them that the file should contain the textcheckbz239239239
.Then, to validate that they followed your directions, (PHP sample)
I'm not an expert in DNS, but my understanding is that DNS is considered to be as secure as the site itself. ie, you can assume its secure, but it is in theory possible for it to be hacked, but at that point, the entire site itself is compromised, which is their problem, not yours.