Write to htaccess file in PHP September 10, 2020 The code below shows an example of how to write to the htaccess file in PHP. The example below will write a new line at the bottom of your htaccess file. The htaccess file should be located in the same folder from which the PHP runs The Code <?php $f = fopen(".htaccess", "a+"); fwrite($f, "\n#This line added via php script"); fclose($f); ?> 12345 <?php$f = fopen(".htaccess", "a+");fwrite($f, "\n#This line added via php script");fclose($f);?> Related PostsExtract all post variables with PHPGet string between with PHPCURL JSON post and response in PHPRecursive function example in PHPUsing json_decode In PHPCustom Index PageGet The Web Address Of A Child Theme In WordPressUsing phpinfo In PHPUsing str_replace In PHPUsing strtolower In PHPMore...