Como usar: .htaccess Generator
- Tick the features you want — HTTPS, canonical host, compression and security headers are on by default.
- Fill in details such as redirects, your domain or allowed IP where needed.
- Copy or download the file and upload it to your site’s root folder as
.htaccess. - Click Test rules to simulate URLs against the generated rewrite rules.
What is .htaccess?
An .htaccess file is a per-directory configuration file for the Apache web server (and LiteSpeed, which reads the same syntax). It is how most shared hosting, WordPress and PHP sites configure redirects, URL rewriting, caching, compression and access control without touching the main server configuration. Rules apply to the folder the file is in and all subfolders.
What each option does
| Option | Effect |
|---|---|
| Force HTTPS | 301-redirects every http:// request; also works behind proxies that set X-Forwarded-Proto |
| Canonical host | One version of the domain — www or not — so search engines do not see duplicates |
| Compression | gzip via mod_deflate, Brotli via mod_brotli when available |
| Browser caching | Long expiry for versioned CSS, JS, images and fonts; HTML always revalidated |
| Security headers | HSTS, X-Content-Type-Options, frame and referrer policies; hides the server signature |
| Block sensitive files | Denies .env, .git, SQL dumps, backups and Composer/npm files |
| Maintenance mode | 503 with Retry-After for everyone except your IP — the SEO-safe way to go offline |
Before uploading
- Keep a copy of your existing file — WordPress and other CMSs add their own block between
# BEGINand# ENDcomments. - A syntax error makes the whole site return 500 Internal Server Error. Check the file with the .htaccess tester first.
- Test redirects in a private window — browsers cache 301 redirects aggressively.
- Your host must allow overrides (
AllowOverride All) and havemod_rewriteandmod_headersenabled.
On Nginx, .htaccess files are ignored — use the Nginx config generator. For many individual redirects, the redirect generator outputs Apache, Nginx and other formats; check the result live with the redirect checker.
Também pesquisado como: .htaccess redirect, htaccess force https, htaccess www redirect, htaccess rewrite rules, htaccess caching, apache htaccess, rewrite rule generator, mod_rewrite generator.
Ferramentas que combinam com: .htaccess Generator
- Apache VirtualHost Generator — Get a complete Apache virtual host config for your domain: a static site, WordPress, PHP-FPM or a reverse proxy to a Node or Python app.
- Htpasswd Generator — Generate user:hash lines for HTTP Basic Authentication in Apache, Nginx, Traefik and Caddy — with bcrypt by default and nothing sent to a server.
- Security Headers Checker — Grade a site’s HTTP security headers from A+ to F, see which are missing and why they matter, and copy ready-made config snippets for Nginx, Apache, Netlify, Vercel or Cloudflare.
- YAML Validator — Paste a Docker Compose file, Kubernetes manifest, GitHub Actions workflow or any YAML to pinpoint errors, catch common pitfalls and get a cleanly formatted version.
Perguntas frequentes
Can it generate rewrite rules?
Where do I put the .htaccess file?
public_html or www). The file name starts with a dot, so enable “show hidden files” in your FTP client or file manager.