php reCaptcha 显示“输入错误:无效引用者”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11999231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
reCaptcha show "input error: invalid referer"
提问by ehsun7b
I have registered an account on recaptcha.net with mydomain.com.
我已经在 recaptcha.net 上用 mydomain.com 注册了一个帐户。
While I'm developing on my localhostit works fine, but whenever I try to open the page from another machine in my local network it shows "input error: invalid referer"error message!
虽然我正在开发我的localhost它工作正常,但是每当我尝试从本地网络中的另一台机器打开页面时,它会显示"input error: invalid referer"错误消息!
I'm not using recaptcha plugins.
我没有使用recaptcha插件。
回答by Nasreddine
reCaptcha keys are tied to a certain domain + localhost (when you got your private/public keys from them). You can use it on another domain by requesting new private/public keys or by using a global key.
reCaptcha 密钥绑定到某个域 + 本地主机(当您从它们那里获得私钥/公钥时)。您可以通过请求新的私钥/公钥或使用全局密钥在另一个域上使用它。
From their website:
从他们的网站:
By default, your reCAPTCHA key is restricted to the specified domain, and any subdomains for additional security. A key for foo.com works on test.foo.com.
If you wish to use your key across a large number of domains (e.g., if you are a hosting provider, OEM, etc.), select the global key option. You may want to use a descriptive domain name such as "global-key.mycompany.com"
If you own multiple domain names (foocars.com and footrucks.com), you can sign up for multiple keys, or use a global key.
默认情况下,您的 reCAPTCHA 密钥仅限于指定的域和任何子域以提高安全性。foo.com 的密钥适用于 test.foo.com。
如果您希望在大量域中使用您的密钥(例如,如果您是托管服务提供商、OEM 等),请选择全局密钥选项。您可能希望使用描述性域名,例如“global-key.mycompany.com”
如果您拥有多个域名(foocars.com 和 footrucks.com),您可以注册多个密钥,或使用全局密钥。
回答by Andre Ravazzi
It seems that Google has removed the Global Key for reCaptcha, as you can see here.
谷歌似乎已经删除了 reCaptcha 的全局密钥,你可以在这里看到。
In your localhost it works fine because your are using the keys provided to your domain. But when you upload the code you your production server, it seems that you are using the same keys to multiple domains (even though localhost might not be considered a domain). So you got that error. I fixed that creating new keys to another domain of mine and adding them to my localhost script. And to the production script, I kept the keys for that domain.
在您的本地主机中它工作正常,因为您使用的是提供给您的域的密钥。但是,当您将代码上传到您的生产服务器时,您似乎对多个域使用了相同的密钥(即使 localhost 可能不被视为域)。所以你得到了那个错误。我修复了为我的另一个域创建新密钥并将它们添加到我的本地主机脚本的问题。对于生产脚本,我保留了该域的密钥。
回答by erhun
i have the same problem, i solve it to add my server ip adress from recaptcha admin screen;
我有同样的问题,我解决了它从recaptcha管理屏幕添加我的服务器IP地址;
Click the over your domain name which are listed under header Your reCAPTCHA sitesand add your ip at Key Settings -> Domainso problem is solved.
单击标题下列出的域名, Your reCAPTCHA sites然后添加您的 ip,Key Settings -> Domain这样问题就解决了。
回答by Hexodus
As Andre mentioned before - the global key was removed for reCaptcha. But you can use secure tokenYou'll find my solution for PHP here
正如安德烈之前提到的 - 删除了 reCaptcha 的全局密钥。但是你可以使用安全令牌你会在这里找到我的 PHP 解决方案

