I think I know why CAPTCHA images are broken
-
I spent most of the today working around this problem and I think I have an answer that might be useful.
I put a “Contact Us” form on the website I’m rebuilding at https://www.infrasupport.com. But for the life of me, that CAPTCHA image wouldn’t show up. Just an ugly looking placeholder graphic. There are a bunch of others complaining about similar problems.
But I have an advantage that I’m hosting my own website, so I can dig deeper into the hosting environment than most others.
The documentation on the new CAPTCHA version gives us a huge clue the latest version of ReallySimple CAPTCHA creates a tmp file and uses that for the image with the letters.
Wonderful. There’s probably a good reason for it. Where does it create the tmp file?
I’ve learned to watch the httpd error log when these goofy errors come up. So watching /etc/httpd/logs/error_log on my web host in one window and accessing my Contact-7 form with the CAPTCHA in a browser, I saw this error message:
[Mon Dec 22 17:39:16.520819 2014] [core:alert] [pid 2368] [client 10.10.10.1:59380] /usr/share/wordpress/wp-content/uploads/wpcf7_captcha/.htaccess: order not allowed here, referer: https://www.infrasupport.com/contact-us/
Huh? That’s a head-scratcher.
Looking at that directory – well, whaddya know – there’s a .htaccess file. Here’s what it looks like:
Order deny,allow Deny from all <Files ~ "^[0-9A-Za-z]+\.(jpeg|gif|png)$"> Allow from all </Files>
That’s where it puts its tmp file – so it has to liberalize the permissions so it can write it. OK, fair enough – so why the obvious syntax problem in this plugin-generated .htaccess file? Apparently the “Order” directive is out of place here. But surely the plugin author tested this – surely it doesn’t fail in all cases. Why does it fail for me?
The only thing I can think of is, on my system, I put my website in a <Virtualhost> directive in a .conf file I setup in /etc/httpd/conf.d. Maybe the .htaccess file syntax is different when it’s managing a directory inside a VirtualHost? I don’t know.
My workaround – I put it inside my infrasupport.conf file that describes the whole website. I’m running into a bunch of other directories that other plugins need and collecting all the pieces in my master .conf file. It’s growing into a monster.
Maybe the WordPress developers might want to think about a common method to handle all these tmp files that various plugins neeed, instead of every plugin doing its own thing its own way and driving webmasters crazy.
My workaround was to comment out everything in that .htaccess file and put the directives in my own infrasupport.conf file, which loads when httpd restarts.
For others without the luxury of owning your own hosting environment, maybe tinkering with that auto-generated .htaccess file is the best workaround. The good news – the CAPTCHA plugin looks like it generates a new .htaccess file if it doesn’t exist, but if you edit it by hand, near as I can tell, CAPTCHA leaves it alone. So if you can find a syntax that works and put it in your .htaccess file, CAPTCHA should work.
– Greg Scott
- The topic ‘I think I know why CAPTCHA images are broken’ is closed to new replies.