Generador de redirecciones .htaccess
GeneratorsGenera reglas de redirección de Apache .htaccess desde un editor sencillo: redirecciones por ruta con 301, 302 o 308, además de bloques de forzado de HTTPS y de canonicalización de www. Funciona en local con un enlace para compartir.
(Documentación en inglés)
What it does
Builds an Apache .htaccess file from a simple editor instead of hand-written directives. Each rule is a from-path, a target and a status code — 301 permanent, 302 found, or 308 permanent preserving the method. On top of the redirects you can add a force-HTTPS block and www canonicalization (either direction) with their RewriteCond/RewriteRule pairs. Input is validated as you type: paths must start with / and contain no spaces, duplicate from-paths, conflicting canonical directions and protocols in the domain are all named errors. Everything runs locally in your browser.
How to use it
- Fill redirect rows under Redirect rules: a source path like
/old-blog, a target like/blogor a full URL, and a status code. Add rule appends a row, the × removes one. Sample loads two example rules. - Under Server rules, flip Force HTTPS and/or a www → apex / apex → www direction. Picking a canonical direction reveals the domain field (a bare host, like
example.dev). - The generated file appears live on the right, sections ordered: HTTPS first, canonicalization second, redirects last.
- Copy takes the file; Download saves it as
.htaccess. - Copy share link encodes the whole configuration in the URL.
Examples
One redirect:
Redirect 301 /old-blog /blog
Force HTTPS plus www→apex on example.dev produces an <IfModule mod_rewrite.c> block with RewriteEngine On, a %{HTTPS} off condition redirecting to https://%{HTTP_HOST}…, and a ^www\.example\.dev$ condition redirecting to the apex — dots escaped so the pattern cannot match lookalikes.
Validation example: a second rule with the same from-path reports Duplicate "from" path: /old-blog; https://example.dev in the domain field reports that the protocol must be removed.
Which status code to pick
| Code | Meaning | Use when |
|---|---|---|
| 301 | Moved Permanently | the move is forever — search engines transfer ranking |
| 302 | Found (temporary) | the move may be undone — ranking stays with the old URL |
| 308 | Permanent Redirect | like 301, but POST stays POST (no method rewrite to GET) |
The canonical blocks always emit 301. Place the file in your site root; Apache picks it up per-directory — and because the blocks are wrapped in <IfModule mod_rewrite.c>, a host without mod_rewrite skips them instead of erroring.