Assemble common Apache .htaccess rules — HTTPS and www redirects, caching, compression, security headers and more — in a click. Free, in your browser.

Always back up your existing .htaccess before replacing it. A single wrong directive can take your whole site offline.
.htaccess 0

					

About .htaccess Generator

The .htaccess generator assembles battle-tested Apache configuration snippets into one file. Toggle on what you need: force HTTPS, canonical www or non-www redirects, disabled directory listings, custom 404/500 error pages, Gzip compression via mod_deflate, browser caching with Expires headers, security headers, hotlink protection, IP blocking, default index files and forced file downloads by extension.

Each option is a documented block, so the resulting file stays readable and easy to prune later. Redirect rules use your actual domain, which you enter once, and the security-header set applies common hardening responses without breaking normal pages.

The generator runs entirely in your browser — nothing is uploaded. Copy the output or download .htaccess, but always back up your existing file first: a single wrong directive can take a whole Apache site offline.

How to use .htaccess Generator

  1. Enter your domain so the redirect rules are generated for the right host.
  2. Toggle on the rules you need: HTTPS redirect, www or non-www, directory listing off, error pages, compression, caching, security headers, hotlink protection, IP blocking, index files or forced downloads.
  3. Fill in the per-option fields, such as the 404/500 page paths or the IP addresses to block.
  4. Review the assembled file in the output panel.
  5. Copy it or download .htaccess, back up your current file, then upload the new one to your site root.

Frequently asked questions

HTTPS enforcement, www/non-www canonical redirects, disabled directory listings, custom error pages, Gzip (mod_deflate) compression, browser-cache Expires headers, security headers, hotlink protection, IP blocking, default index files and forced file downloads.

Either works — what matters is picking one canonical host and redirecting the other, so search engines and analytics see a single version of every URL.

Restore the backup of your previous .htaccess — this is why the tool reminds you to back up first. Apache applies the file immediately, so a bad directive can return 500 errors sitewide.

No. .htaccess is Apache-specific (also honored by LiteSpeed). Nginx uses its own configuration syntax, so these rules would need translating.

Yes. It is free, and the file is composed in your browser — your domain and rules are never uploaded.

Need help?
Found an issue with this tool? Let our team know.
Report an issue

Add this free tool to your own website — copy and paste the code below.