How to prevent WordPress from overwriting your rewrite rules

Provided the permissions are properly set on the .htaccess file, WordPress will update it with its own rewrite rules whenever the “Save Changes” button on Settings > Permalinks is clicked, like so:

# 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]

# END WordPress

In order to prevent WordPress from overwriting any additional rewrite conditions or rules you might have in the .htaccess file (such as instructions to redirect from WWW to non-WWW or HTTP to HTTPS, for example), put them either before # BEGIN WordPress or after #END WordPress.