Jump to content


google recaptcha V2 on apache shared server: How to get it to work with SSL

ssl apache shared server recaptcha htaccess

  • Please log in to reply
1 reply to this topic

#1 tork

  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 29 November 2014 - 12:11 AM

I implemented google's reCAPTCHA V2 on http:// on the remote apache shared server and it worked 100%. I then changed the protocol to my shared server SSL using the same PHP script as the non-SSL script. The older version of reCaptcha had an SSL 'false' to 'true' SSL parameter, whereas I can't find one for V2. I had to use htaccess to redirect the example.com to the shared SSL server https://serverid.net/example/ which works perfectly without recCAPTCHA. I incorporated reCAPTCHA V2 and the error message where the reCAPTCHA image should be shows "ERROR: Invalid domain for site key".
Here's the htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://servername.net/example/$1 [R,L]

And the recaptchalib.php code in case that helps:


Anyone know how to make this work?


(If this is not the right forum for this, please direct me to the appropriate one. Thx)

#2 jeffreyappel

  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 08 April 2015 - 10:13 AM

You register your key under example.com. So google reCAPTCHA server expects that user load it from domain http://example.com. Now you display it in http://serverid.net/ which is different with http://example.com  and  rendering the error message.

Essay writing service by Pimion

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users