.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.
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).
Common Use Cases
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?
Why does the downloaded file get named "htaccess" instead of ".htaccess"?
Can I enable more than one recipe at a time?
Should I pick "Add www" or "Remove www" for the WWW Redirect recipe?
Will this conflict with rules I've already added to my own .htaccess file?
Is anything I configure or generate sent anywhere?
Related Tools
View all GeneratorsLorem Ipsum Generator
Generate paragraphs, sentences, or words of placeholder text for mockups and designs.
Random Number Generator
Generate random numbers with custom ranges, quantity, and sorting options for testing and development.
QR Code Generator
Generate and download QR codes for any URL or text. Customize size, colors, and error correction level.