.htaccess Generator
Toggle the rules you need, HTTPS, www, redirects, caching, compression, and get a clean, commented Apache .htaccess file. Built in your browser.
Redirect all http traffic to https.
Compress text, CSS, JS, JSON, SVG.
Far-future expiry for images, fonts, CSS, JS.
Stop Apache listing folder contents.
/old /new [301|302]A correct .htaccess without the guesswork
The Apache .htaccess file controls redirects, HTTPS, caching, and access rules per-directory, and
a single misplaced RewriteRule can take a site down. This generator assembles the common rules from
toggles into one clean, commented file, in the right order, with the mod_rewrite and
mod_headers blocks set up correctly.
What it can build
- Force HTTPS and a canonical www / non-www host (do pick one, split hosts hurt SEO).
- 301/302 redirects: plain paths use
Redirect; patterns with(.*)and$1becomeRewriteRules. - gzip compression and far-future browser caching for static assets.
- Disable directory browsing and set a custom 404.
FAQ
Where does the file go?
In the directory you want it to govern, usually your site root. Rules cascade to subdirectories unless overridden. Apache must have AllowOverride enabled for it to take effect.
301 or 302?
301 is permanent, use it when a URL has moved for good, so search engines transfer ranking. 302 is temporary. Default here is 301.
Is anything uploaded?
No, the file is generated in your browser from your toggles. Nothing is sent anywhere.
Related
Building redirect patterns? The case converter helps slug URLs; test JSON configs with JSON → TypeScript.