$file = 'my/path/to/htaccess/location/.htaccess';
$htaccess = file($file);
$ht = fopen($htaccess,'a');
fwrite($ht,"deny");
fclose($ht);
I'm trying to modify the .htaccess file via functions.php, the CHMOD is set to 777, any ideas?
Edit:
Just enabled errors:
Warning: file() [function.file]: URL file-access is disabled in the server configuration in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 133
Warning: file(http://themes.ibrogra.com/beta/.htaccess) [function.file]: failed to open stream: no suitable wrapper could be found in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 133
Warning: fopen() [function.fopen]: Filename cannot be empty in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 135
Warning: fwrite(): supplied argument is not a valid stream resource in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/beta/functions.php on line 137
Warning: fclose(): supplied argument is not a valid stream resource in /home/tfbox/domains/ibrogram.com/public_html/themes/beta/wp-content/themes/bet开发者_如何转开发a/functions.php on line 139
This
$file = 'http://'.$_SERVER['SERVER_NAME'].'/beta/.htaccess';
makes the requested path a http path.
That doesn't make sense - you want to use a file path.
You could use
$file = $_SERVER['DOCUMENT_ROOT'].'/beta/.htaccess';
instead.
精彩评论