From my custom plugin, on activation, i want add some rules into htaccess but at beginning of the file.
insert_with_markers add the rule at the end of htaccess, eg.:
$lines = array();
$lines[] = '# MY RULES';
return insert_with_markers(ABSPATH . '.htaccess', 'TEST', $lines);
result
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN TEST
# MY RULES
# END TEST
expected
# BEGIN TEST
# MY RULES
# END TEST
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
how add my rules at beginning of htaccess?