.htaccess Generator

Assemble a working Apache .htaccess file by checking off common recipes: force HTTPS, www redirects, gzip compression, browser caching, and a custom 404 page.

runs locally on your browser. Your data never leaves your device.

Recipes

Browsers won't save a download with a name that starts with a dot, so the file saves as "htaccess"; rename it to ".htaccess" after saving (copying instead avoids this, since you paste directly into a file you name yourself).

0Recipes enabled
0Lines generated

Common Use Cases

Force HTTPS and a single canonical hostname on a new site before it goes live
Add gzip compression and browser caching headers to speed up an existing Apache-hosted site
Point Apache at a custom-designed 404 page instead of the server's generic default
Quickly regenerate a clean .htaccess after migrating a site to a new Apache host

About .htaccess Generator

An Apache .htaccess file controls per-directory server behavior, including redirects, compression, caching headers, and custom error pages, without needing access to the main server configuration. The syntax is terse and easy to get subtly wrong by hand: a missing RewriteCond, a directive placed outside the right IfModule block, or a regex that redirects one hostname variant but not another. This generator assembles a working file from a short list of common, well-tested recipes instead.

Check off any combination: Force HTTPS redirects every HTTP request to HTTPS; WWW Redirect enforces a single consistent hostname (either adding or removing the "www." prefix, your choice); Gzip Compression wraps mod_deflate around common text-based MIME types (HTML, CSS, JavaScript, JSON, SVG, and more) so pages transfer smaller; Browser Caching sets mod_expires headers so images, fonts, and stylesheets aren't re-downloaded on every visit; and Custom 404 Page points ErrorDocument at whatever path you serve your own not-found page from. Enabling both Force HTTPS and WWW Redirect combines them into a single shared <IfModule mod_rewrite.c> block with one RewriteEngine On line, rather than two redundant blocks.

The output panel updates live as you toggle recipes, in a fixed order every time, so the generated file is identical no matter what order you clicked the checkboxes in. Copy it to your clipboard and paste it into a file named ".htaccess" in your site's root (or the directory you want the rules to apply to); browsers won't let a downloaded file's name start with a dot, so the download button saves a plain file named "htaccess" that needs renaming afterward; copying avoids that entirely, since you paste into a file you create and name yourself. Everything, from the recipes to the assembly and the live preview, runs as plain JavaScript in your browser tab; nothing you configure or generate is ever uploaded to a server, logged, or stored.

Frequently Asked Questions

Where do I put the generated .htaccess file?
Save it as ".htaccess" (no other name works; Apache looks for that exact, case-sensitive filename) in the root directory of your site, or in a subdirectory if you only want the rules to apply there. Your hosting environment needs mod_rewrite, mod_deflate, and/or mod_expires enabled for the corresponding recipes to take effect: most shared hosts enable all three by default.
Why does the downloaded file get named "htaccess" instead of ".htaccess"?
Browsers strip a leading dot from a downloaded file's name as a safety measure, so a download can never come through named exactly ".htaccess" no matter what this (or any) site requests. Rename the downloaded "htaccess" file to ".htaccess" after saving it, or avoid the issue entirely by using the copy button and pasting the result into a file you create and name yourself.
Can I enable more than one recipe at a time?
Yes, that's the point. Enable any combination (for example Force HTTPS + WWW Redirect + Browser Caching) and the output combines all of them into one file, in the same fixed order every time regardless of which order you toggled them in.
Should I pick "Add www" or "Remove www" for the WWW Redirect recipe?
Whichever hostname you actually want visitors and search engines to land on. "Add www" redirects a bare domain (example.com) to the www version (www.example.com); "Remove www" does the opposite. Pick one and stick with it: serving the same content at both is what this recipe exists to prevent, since search engines otherwise treat them as duplicate content.
Will this conflict with rules I've already added to my own .htaccess file?
This tool generates a complete, standalone file rather than editing an existing one, so if you already have custom rules, merge them by hand afterward: paste the generated blocks into your existing file rather than overwriting it, and keep only one RewriteEngine On line if you already have mod_rewrite rules of your own.
Is anything I configure or generate sent anywhere?
No. The recipes are bundled directly into the page and the assembly happens entirely in your browser using plain JavaScript, so nothing is uploaded to a server, logged, or stored anywhere outside your current browser tab.