.htaccess generator
Build a production-ready Apache .htaccess file: HTTPS enforcement, canonical host redirects,
custom 301s, compression, caching and security basics. The output updates live — copy it or download it as
.htaccess.
Canonical host
Custom 301 redirects
Use relative paths for internal redirects or full URLs for external ones.
Performance
Security & behavior
.htaccess
Upload to your web root (usually public_html/). Test with curl -I https://yourdomain.com after deploying.
Notes on .htaccess
- mod_rewrite required
- Redirect rules need
mod_rewrite. Nearly all shared Apache hosts enable it; if you get a 500 error, check your host's docs or remove the rewrite block. - One redirect at a time
- HTTPS and host canonicalization are separate rules on purpose — combine them in the wrong order and you get redirect loops. Keep them as generated.
- Cache lifetimes
- Long cache times are great for hashed assets (CSS/JS with fingerprints) but risky for images you update often. Use versioned filenames or a CDN purge for changes.
- 500 errors
- A single bad directive can white-screen the site. Keep a backup of the working file, and if the site breaks, rename the file via FTP/file manager to disable it instantly.
Pair this with a security headers file for a hardened setup, or browse all tools.