htaccess-Weiterleitungs-Generator

So wird es benutzt 3 Schritte
  1. Wählen Sie Regeltyp und Statuscode.
  2. Füllen Sie die Pfade oder Domains aus, die die Regel verlangt.
  3. Drücken Sie Regeln erzeugen und übernehmen Sie sie mit Kopieren in Ihre .htaccess-Datei. Legen Sie vorher eine Sicherung an.
.htaccess-Regeln

Die Regeln gehören in der .htaccess über den WordPress-Block, da die WordPress-Rewrite-Regel die Verarbeitung für alles beendet, was sie trifft. Legen Sie vor dem Bearbeiten immer eine Kopie der Datei an: Eine fehlerhafte Direktive liefert einen 500-Fehler für die gesamte Website. Weiterleitungsketten kosten Crawl-Budget – lassen Sie alte URLs direkt auf ihr endgültiges Ziel zeigen statt über einen Zwischenschritt.

So funktioniert dieses Werkzeug

Diese Regeln gehören in die Datei .htaccess auf einem Apache-Server. LiteSpeed liest dieselbe Datei; nginx liest sie überhaupt nicht und braucht eine eigene Konfiguration – prüfen Sie also vor dem Einfügen, was Ihr Hoster einsetzt.

Vier Modi decken die übliche Arbeit ab: ein Pfad auf einen anderen, eine Liste von Paaren im Stapel, eine ganze Domain auf eine neue, sowie www erzwingen oder entfernen. Einzelne Weiterleitungen nutzen eine einfache Redirect-Direktive; Domain- und www-Regeln nutzen Rewrite-Regeln, und Zeichen mit besonderer Bedeutung im Muster – Punkte, Fragezeichen, Pluszeichen – werden maskiert, damit ein wörtlicher Pfad auch wörtlich passt. Sind Quelle und Ziel identisch, wird die Regel abgelehnt, denn das wäre eine Weiterleitungsschleife.

Bevor Sie das auf einer Live-Website einfügen

  • Sichern Sie die Datei zuerst: ein Syntaxfehler in .htaccess liefert auf jeder Seite der Website einen 500er, auch im Adminbereich – dann bleibt nur, die Sicherung per FTP zurückzuspielen.
  • 301 ist dauerhaft, 302 nicht: eine 301 gibt Ranking-Signale weiter und wird von Browsern hartnäckig zwischengespeichert, sodass eine falsch gesetzte noch lange weiterleitet, nachdem Sie den Server längst korrigiert haben. Verwenden Sie 302, solange etwas unsicher ist.
  • Die Reihenfolge zählt: Regeln werden von oben nach unten angewendet, und eine breite Regel oberhalb einer engen verhindert, dass die enge jemals greift.
  • Leiten Sie auf die entsprechende Seite weiter: jede entfernte URL auf die Startseite zu schicken, wird als Soft 404 gewertet und gibt nichts weiter. Eine inhaltlich nahe Entsprechung oder ein ehrlicher 410 ist besser.

301 or 302 — the choice that matters

A 301 is permanent. It tells search engines the page has moved for good, passes the ranking signals to the new URL, and is cached by browsers — often indefinitely.

A 302 is temporary. Signals stay with the old URL and browsers re-check each time.

Almost every redirect you write should be a 301. Use a 302 only when the old URL will genuinely come back: a page down for maintenance, a seasonal landing page, an A/B test.

The [msm_tool slug="htaccess-redirect-generator"] defaults to 301 for that reason, and it catches the two mistakes that cause the most damage.

Browser caching makes a wrong 301 expensive

This is the part people discover too late. Once a browser has seen a 301 it may never ask again, even after you remove the rule from the server.

So a 301 pointing at the wrong destination is not fixed by deleting it. Visitors who already hit it keep going to the wrong place until their cache clears, which can be weeks. Testing in a private window is not enough — test the rule before it goes near production, not after.

This is also why a 302 is the safer choice while you are still deciding. Switching a 302 to a 301 later costs nothing; switching a bad 301 back costs your visitors.

Loops and chains

A redirect pointing at itself produces an infinite loop and the page becomes unreachable. The generator refuses that outright rather than writing it.

Chains are subtler and more common: A redirects to B, and B was already redirecting to C. Every hop costs time, and search engines stop following after a handful. Each hop also loses a small amount of the signal being passed along.

When you add a redirect, check whether the destination is itself redirected. Point A straight at C and collapse the chain.

Order matters

Apache evaluates rules top to bottom and the first match wins. A broad rule placed above a specific one prevents the specific one from ever running.

Put the most specific rules first and the catch-alls last. This is the usual explanation for "my redirect isn't working" when the syntax is plainly correct.

Redirect and RedirectMatch

The simple Redirect directive takes literal paths and is right for one-to-one moves. It also matches prefixes, which surprises people: a rule for /blog also catches /blog-archive.

RedirectMatch takes a regular expression and is what you want for patterns — moving an entire directory, changing a URL structure, appending or removing a segment. It is more powerful and correspondingly easier to get wrong, so test it against URLs that should not match as well as ones that should.

Bulk redirects

For a site migration, put each old and new address on the same line and generate them together. That is far less error-prone than writing hundreds by hand, and the tool reports how many lines it skipped as incomplete rather than silently dropping them.

Before a migration, export the list of URLs that actually have traffic or backlinks. Redirecting everything is unnecessary; redirecting the pages people reach is essential, and a spreadsheet of old-to-new pairs is the artefact that makes the whole thing survivable.

htaccess is not free

Apache reads the file on every request, for every directory in the path. A file with thousands of rules is measurably slower than one with a few dozen.

If you are on your own server, redirects belong in the main configuration where they are read once at startup. .htaccess exists for shared hosting where you cannot touch that configuration — which is most of the time, and is a good enough reason to use it.

After deploying

  1. Test each rule with a fresh browser profile or a command-line request, checking the status code rather than just the landing page.
  2. Confirm you get one hop, not two.
  3. Watch for a rise in 404s in the server logs for a fortnight afterwards.
  4. Keep the redirects. Removing them a year later breaks every old link that still exists on other people's sites.

Häufig gestellte Fragen

Speziell zum htaccess-Weiterleitungs-Generator. Allgemeinere Fragen zu dieser Kategorie werden auf der Kategorieseite beantwortet.

Nein. Nginx hat eine eigene Konfigurationssyntax und ignoriert .htaccess vollständig. LiteSpeed, das auf vielen Shared-Hosting-Paketen läuft, liest .htaccess und verhält sich hier wie Apache.
In der .htaccess im Web-Root, oberhalb des Blocks, den WordPress zwischen seinen BEGIN- und END-Kommentaren verwaltet. Die Rewrite-Regeln von WordPress beenden die Verarbeitung für alles, worauf sie passen, sodass Weiterleitungen dahinter womöglich nie ausgeführt werden.
301 für alles Dauerhafte – eine verschobene Seite, eine geänderte Domain, erzwungenes HTTPS. 302 beim Testen oder für ein wirklich vorübergehendes Ziel. Bei einer 301 führen Suchmaschinen die Signale auf dem Ziel zusammen, bei einer 302 weitgehend nicht.
Spielen Sie die Sicherung zurück. Ein 500er aus der .htaccess ist fast immer ein Syntaxfehler, eine Direktive, für die dem Server das Modul fehlt, oder ein Rewrite-Block ohne seine RewriteEngine-Zeile.
Ja. Jeder Sprung kostet den Besucher einen zusätzlichen Roundtrip, und lange Ketten werden weniger zuverlässig verfolgt. Leitet eine URL bereits weiter, richten Sie die neue Regel auf das endgültige Ziel aus, statt ein weiteres Glied anzuhängen.

Abonniere Benachrichtigungen zu neuen Tools, Funktionen und Produktivitätstipps.