WordPress keeps writing rewrite rules into .htaccess again and again till it causes an error and causes server to return 500 Internal server error…
i.e. My .htaccess is a series of
# 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 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
repeated over and over and over again.
By itself, that’s not a massive problem (except that my .htaccess will grow to several MBs, slowing down the site significantly). But occasionally, there would appear some garbage in the .htaccess which takes the site down (500 Internal Server Error)
I am not sure why this happens, but you can stop all write access to your .htaccess with a simple filter:
Neither WordPress nor any plugins calling
flush_rewrite_rules()
will write something into the file now. Other methods to access and change the file will still work, for exampleinsert_with_markers()
.For me just a resetting of WordPress Permalinks fix the problem!