@nosoynadie – I made the change:
if ( $handle = @fopen( $htaccess_file, 'w' ) ) {
fwrite( $handle, '<IfModule mod_rewrite.c>' ."\n".'RewriteEngine Off'."\n".'</IfModule>' . "\n" );
fwrite( $handle, 'Order deny,allow' . "\n" );
fwrite( $handle, 'Deny from all' . "\n" );
But that was still broke for me so I removed it.
What did work for me was looking at the error log, which stated:
[Sat Jul 05 07:32:52 2014] [alert] [client 69.165.217.125] /var/www/wordpress/wp-content/uploads/wpcf7_captcha/.htaccess: allow not allowed here
So, checking in my case /etc/apache2/sites-enabled/wordpress.conf I see:
<Directory /var/www/wordpress>
Options FollowSymLinks
AllowOverride FileInfo Options
Now according to https://serverfault.com/questions/543789/why-is-allow-not-allowed-here-in-apache2 and https://httpd.apache.org/docs/2.2/mod/core.html#allowoverride , to let .htaccess perform this job this line needs to include Limit, i.e. be:
AllowOverride FileInfo Options Limit
Then it works for me. YMMV.