.htaccess and Nginx Config Generator

Generate Apache and Nginx snippets for allow/block routes, CORS, HTTPS, and www redirects.

Permite respostas com headers CORS (origem, metodos e headers) para chamadas de outro dominio. Permite respuestas con headers CORS (origen, metodos y headers) para llamadas desde otro dominio. Adds CORS response headers (origin, methods, and headers) for cross-domain requests.

Quando ativo, localhost e faixas privadas (127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x e ::1) passam mesmo com bloqueios de rota. Cuando esta activo, localhost y rangos privados (127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x y ::1) pasan incluso con bloqueos de ruta. When enabled, localhost and private ranges (127.0.0.1, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, and ::1) are allowed even with route blocking.

Redireciona HTTP para HTTPS (301). Redirige HTTP a HTTPS (301). Redirects HTTP to HTTPS (301).

Redireciona domínio sem www para versao com www. Redirige dominio sin www a version con www. Redirects non-www host to www.

Overview

Apache HTTP Server was launched in 1995 by a group of developers patching and extending NCSA HTTPd, the web server Marc Andreessen and Eric Bina had written at the University of Illinois. The name Apache was a play on words for a server full of patches — though the Apache Software Foundation has softened that etymology over the years. The `.htaccess` file is a direct inheritance from that legacy: it was the mechanism NCSA HTTPd used to let directory owners configure access without needing superuser privileges on the server. In Apache, `.htaccess` is read on every request for every directory in the path — convenient on shared hosting where you have no access to `httpd.conf`, but a performance concern in production because each request may open and read several `.htaccess` files from disk.

Nginx was born from a completely different need. Igor Sysoev, a Russian engineer working at Rambler — the largest Russian internet portal at the time — wrote Nginx in 2002 and released it as open source in 2004 to solve the C10K problem: how to handle 10,000 simultaneous connections on a single server. Apache uses a process or thread per request model — each connection occupies a worker. That works fine for hundreds of connections, but not for tens of thousands. Nginx uses an event-driven, non-blocking model: a small number of workers handle all connections using `epoll` on Linux and `kqueue` on BSD. The practical result is that Nginx consumes orders of magnitude less memory per connection. That is why today it is the preferred server for serving static files, reverse proxying, and TLS termination in front of Node.js, PHP-FPM, and Python applications.

The fundamental philosophical difference between the two shows in their configurations. Apache uses per-directory `.htaccess` files, context inheritance, and modules like `mod_rewrite` with its `RewriteRule` and `RewriteCond` syntax. Nginx uses `server {}` and `location {}` blocks in a central configuration file — there is no equivalent to `.htaccess`. For those migrating from one to the other, the most common translation is from `RewriteRule` to `rewrite` or `try_files` in Nginx. This tool generates the most repeated snippets: redirecting HTTP to HTTPS, www to non-www or vice versa, configuring CORS with `Access-Control-Allow-Origin` headers, blocking access to sensitive routes, and enabling static file caching. Generate, understand what each line does, and adjust to your environment before going to production — a misconfiguration in these rules can make the entire site unreachable.

Technical deep dive

Common questions summarized

  • What is this tool for?: It runs fully in your browser: useful to validate, format, or convert data in everyday development.
  • Are my inputs sent to a server?: Processing happens locally with JavaScript. We do not store what you paste into the text areas.
  • Can I use this for real production data?: Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.

Sample payload to try

  • See also the larger "Code Snippets" sample; paste this excerpt to try locally: Common case — Bloquear /admin antigo, liberar /api e habilitar CORS para frontend.

Tool guide

  • What .htaccess and nginx.conf are Server configuration files for web rules. In Apache, .htaccess often handles rewrites, access control, and headers. In Nginx, equivalent logic is configured in server and location blocks.

  • What the tool does Generates Apache and Nginx snippets for common needs: allow/block specific routes, configure CORS (origin, methods, headers), force HTTPS, and optionally redirect to www.

  • Why use it Useful for fast troubleshooting and initial setup. Instead of writing everything from scratch, you start from a consistent baseline and adjust to your environment.

  • Important precautions Validate in staging before production. Rewrite and route rules vary by app structure, reverse proxy, CDN, and server version. Keep CORS as strict as possible.

Code Snippets

Code example
Bloquear /admin antigo, liberar /api e habilitar CORS para frontend.

Common case

Bloquear /admin antigo, liberar /api e habilitar CORS para frontend.

FAQ

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.