.htaccess Generator

🔒 Processed 100% in your browser — nothing is uploaded

About this tool

Apache's .htaccess is a per-directory configuration file that quietly runs on every request inside the folder it lives in — and the average site needs the same handful of well-known blocks: an HTTPS redirect, a host canonicalization (with or without www), a redirect to clean error pages, an image hotlink block, gzip compression, long-lived caching for static assets, and a way to deny abusive IPs. This generator turns each of those recipes into a checkbox. Pick the ones you want, fill in the variables (your own domain for the hotlink allow list, the IPs to block), and get a complete .htaccess with the selected blocks stitched together in the order they should run, each preceded by a comment marking which recipe produced it. Every recipe carries a one-line description of what it does and a risk note so you know what could go wrong: HTTPS redirects before HSTS, hotlink rules breaking image proxies, CAA records blocking a CA. Nothing is uploaded — generation runs locally and the output copies straight to your clipboard, or downloads as a .htaccess file you can drop into the document root. Keep a backup of the existing file, test on staging, and verify after deployment with curl -I to make sure each toggle behaves the way you expected.

How to use .htaccess Generator

  1. Tick the recipes you want — each one shows what it does and the main risk so you know what to verify after deploy.
  2. Fill in any inputs the recipe needs (your domain for hotlink allowlisting, the IPs/CIDRs to block).
  3. Read the generated file in the preview area; toggle a recipe off and the preview updates instantly.
  4. Copy the .htaccess or download it as a file, back up your existing one, and ship through your normal deploy pipeline.

Frequently asked questions

Will every recipe run on every shared host?

Most yes. Apache 2.4 is universal on shared hosts, and mod_rewrite, mod_deflate, mod_expires and mod_headers are enabled by default on any host that supports .htaccess at all. Each generated block is wrapped in <IfModule> so a missing module makes the block a no-op rather than a server error.

How do I know which IP addresses to block?

Pick them from your access log: look for non-user-agent strings, brute-force POSTs to wp-login or xmlrpc.php, or referrers that are clearly junk. For ongoing protection run fail2ban (which can write to .htaccess automatically) or block at the firewall — Apache is the slow line at high IP counts.

Can I undo a recipe after deploying?

Yes — keep a backup of the original .htaccess, then either delete the file (Apache falls back to its parent config for that directory) or paste a clean replacement. Recipes inside <IfModule mod_rewrite.c> rely on RewriteEngine being enabled; the recipe blocks are deliberately ordered so a single misbehaving block does not stop the rest of the file from being parsed.

Is my .htaccess sent anywhere?

No. The recipes are formatted by JavaScript in your browser and the result is copied or downloaded as a local file. Generation never makes a network call.