WordPress .htaccess generator
The standard Apache rewrite block for single-site or multisite, plus optional hardening rules.
WordPress rewrites everything between # BEGIN WordPress and # END WordPress, so hardening rules are placed above that block. Back up the current file first. On nginx, LiteSpeed without .htaccess support, or IIS, these rules are ignored — the equivalents belong in the server configuration.
Quick answers
Where does the WordPress .htaccess file live?
In the site's root directory, alongside wp-config.php — the same folder wp-login.php is in. Multisite subdirectory networks use one .htaccess at the root; multisite subdomain networks do too, with different rewrite rules.
Why do my custom rules keep disappearing?
WordPress rewrites everything between # BEGIN WordPress and # END WordPress whenever permalinks are saved. Rules placed inside that block are overwritten; place custom rules above or below it instead, as this generator does.
Does this work on nginx?
No — .htaccess is an Apache (and LiteSpeed-with-Apache-compatibility) mechanism. On nginx the equivalent rules belong directly in the server block; see the HTTPS redirect loop guide for an nginx example of the TLS-redirect rule.