About the .htaccess Generator
Apache reads .htaccess on every request in each directory, so rules apply without a server restart. They only work if the virtual host allows it with AllowOverride All (or the specific groups FileInfo, Options, Indexes, AuthConfig). Redirects use mod_rewrite; each block is wrapped in <IfModule> so a missing module does not cause a 500 error.
HTTPS and www canonicalisation are combined into one rule so visitors get a single 301 hop instead of two. Behind a load balancer or Cloudflare, Apache sees plain HTTP, so enable the proxy option to test X-Forwarded-Proto and avoid redirect loops. Custom redirects are matched exactly with escaped patterns, so /old.html does not also match /oldXhtml.
Caching uses mod_expires: HTML revalidates on every visit while images, fonts, CSS and JS can be cached for up to a year if your file names change on deploy. Enable HSTS only after HTTPS works on every subdomain — browsers remember it for the whole max-age. IP blocks use Apache 2.4 Require not ip syntax.
How to use it
- Enter your domain and choose HTTPS and www behaviour.
- List any 301 redirects, one per line: old path, then new path or URL.
- Tick compression, caching, security headers and access rules.
- Copy or download the file and upload it as .htaccess to your site root.
- Test redirects with curl -I before relying on them.