About the .htaccess Generator
Most sites on Apache hosting need the same handful of .htaccess rules, and getting the rewrite syntax right from memory is error-prone. This generator assembles them from checkboxes: redirect HTTP to HTTPS, force or strip www, remove trailing slashes, serve .html files without the extension, set browser caching headers by file type, enable compression, and add basic security headers.
The output is commented so you can see what each block does and remove what you do not need. Rules use mod_rewrite, mod_expires, mod_deflate and mod_headers, which are enabled on nearly all shared hosting; each block is wrapped in a module check where appropriate so a missing module does not break the site.
Test on a staging site first, since a wrong redirect rule can loop. For bulk redirects from a list of old and new URLs, use the Redirect Generator.
How to use
- Tick the rules you need.
- Copy the generated .htaccess.
- Upload it to your site root and test.
Common questions
- Will forcing HTTPS and www together cause a loop?
- No, the generated rules are ordered to avoid that, but always test on staging.
- What if a module is missing on my host?
- Caching, compression and header blocks are wrapped in IfModule checks, so they are skipped rather than causing an error.
- Does this work on Nginx?
- No. .htaccess is Apache-specific. Nginx uses its own configuration syntax.