Skip to content
cosmodev ~/tools/htaccess-generator

.htaccess-redirectgenerator

Generators

Genereer Apache .htaccess-redirectregels vanuit een eenvoudige editor: redirects per pad met 301, 302 of 308, plus force-HTTPS- en www-canonisatieblokken. Draait lokaal met een deelbare link.

Omleidingsregels
Serverregels
HTTPS forceren
Canonieke host

(Documentatie in het Engels)

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

  1. Fill redirect rows under Redirect rules: a source path like /old-blog, a target like /blog or a full URL, and a status code. Add rule appends a row, the × removes one. Sample loads two example rules.
  2. 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).
  3. The generated file appears live on the right, sections ordered: HTTPS first, canonicalization second, redirects last.
  4. Copy takes the file; Download saves it as .htaccess.
  5. 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.

Broncode14 talen

100% client-side · je gegevens verlaten je browser nooit. Handig gevonden? Deel hem met een collega.