Esta página ainda não foi traduzida para o português, por isso aparece em inglês.

.htaccess Generator for Apache

Tick the rules you need — HTTPS, canonical host, redirects, compression, caching, security headers, protected files — and get a clean, commented .htaccess file.

Atualizado em

URLs & redirects

Performance

Security

Seus dados nunca saem do seu computador. Todo o processamento acontece localmente no navegador.

Como usar: .htaccess Generator

  1. Tick the features you want — HTTPS, canonical host, compression and security headers are on by default.
  2. Fill in details such as redirects, your domain or allowed IP where needed.
  3. Copy or download the file and upload it to your site’s root folder as .htaccess.
  4. 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

OptionEffect
Force HTTPS301-redirects every http:// request; also works behind proxies that set X-Forwarded-Proto
Canonical hostOne version of the domain — www or not — so search engines do not see duplicates
Compressiongzip via mod_deflate, Brotli via mod_brotli when available
Browser cachingLong expiry for versioned CSS, JS, images and fonts; HTML always revalidated
Security headersHSTS, X-Content-Type-Options, frame and referrer policies; hides the server signature
Block sensitive filesDenies .env, .git, SQL dumps, backups and Composer/npm files
Maintenance mode503 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 # BEGIN and # END comments.
  • 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 have mod_rewrite and mod_headers enabled.

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?
Yes. It writes Apache mod_rewrite rules (RewriteEngine, RewriteCond and RewriteRule) for HTTPS, www or non-www, trailing slashes and redirects. Test them afterwards with the .htaccess Tester.
Where do I put the .htaccess file?
In your website’s document root (often public_html or www). The file name starts with a dot, so enable “show hidden files” in your FTP client or file manager.
Why does my site show a 500 error after editing .htaccess?
Apache found a syntax error or a directive that is not allowed. Restore the previous file, then check the new one in the .htaccess tester.
Does .htaccess work on Nginx?
No. Nginx ignores .htaccess files; the same rules must be written in the server block.
Is a 301 redirect good for SEO?
Yes. A 301 tells search engines the move is permanent and passes ranking signals to the new URL.
Posso instalar o .htaccess Generator como um aplicativo da web e usá-lo offline?
Sim. O .htaccess Generator é um aplicativo da web instalável (PWA) — instalado a partir do seu navegador, não baixado de uma loja de aplicativos. Clique em “Instalar aplicativo” na parte superior desta página no Chrome ou no Edge (Windows, macOS, Linux, ChromeOS) ou, no Android, use “Compartilhar” → “Adicionar à tela inicial” no iPhone e no iPad, ou “Arquivo” → “Adicionar ao Dock” no Safari 17+ em um Mac. Em seguida, ela se abre em uma janela própria com seu próprio ícone e, como é executada inteiramente no seu navegador, continua funcionando offline. O Firefox no desktop não permite a instalação de aplicativos da web. Como funciona a instalação.

Ferramentas relacionadas