I want to update my .htaccess file using PHP.
I have a section with comments and rules which I would like to read, update and then write back to the htaccess
So far I get read the contents, but all the contents get read.
How can i start reading the file contents at my comment, update the comment and write back to the htaccess?
My code so far:
$htaccess = $_SERVER['DOCUMENT_ROOT'].'/.htaccess';
$content = file_get_contents($htaccess);
$start = '# Restrict START #';
$end = '# Restrict END #';
My .htaccess file contents:
# Restrict START #
deny from all
allow from 127.0.0.1 # Localhost
# Restrict END #
My matches array is empty though