Developer Tool

.htaccess Redirect Generator

Apache redirect rule snippet. Use it online on EasyTools99.

Tool area

Everything runs in the browser.

Reference results

InputResult
Source = /old-guide Destination = https://example.com/guides/setup/Redirect 301 /old-guide https://example.com/guides/setup/
Source = /catalog Destination = https://example.com/products/Redirect 301 /catalog https://example.com/products/
Source = /request-demo Destination = https://example.com/demo/Redirect 301 /request-demo https://example.com/demo/
Source = /events/spring Destination = https://example.com/calendar/spring/Redirect 301 /events/spring https://example.com/calendar/spring/
Source = /support/manual Destination = https://example.com/help/manual/Redirect 301 /support/manual https://example.com/help/manual/
Source = /newsletter-signup Destination = https://example.com/newsletter/Redirect 301 /newsletter-signup https://example.com/newsletter/

How it works

The generator inserts the source path and target URL after the Apache Redirect 301 directive. Apache matches a path prefix and appends the remaining path to the target. To match one exact path, use RedirectMatch with a regular expression anchored with ^ and $. Check the status and Location header for both the source address and a child path.

Worked examples

  1. Move a guide into a new collection.

    An editor moves a guide into a new collection and opens an old bookmark to see whether it reaches the replacement directly.

  2. Move a catalogue and check its child paths too.

    Source = /catalog
    Destination = https://example.com/products/
    Redirect 301 /catalog https://example.com/products/

    A catalogue owner tests product paths underneath the old collection prefix. She decides which products should move with the collection and verifies their destination pages.

  3. Move an old demo-request address to its replacement.

    Source = /request-demo
    Destination = https://example.com/demo/
    Redirect 301 /request-demo https://example.com/demo/

    A sales coordinator moves a demo request page and follows the previous URL to check that the new form still offers the same appointment.

Common mistakes

  • Avoid pointing the destination back to the source. Two rules can produce a loop.
  • Put a path in the source field and an absolute URL in the target field.
  • Verify whether the move is permanent before using a 301. A temporary change can require a different response status.

Technical reference

Apache Redirect directive

FAQ

How do I generate an Apache 301 redirect?

Enter the old path starting with a slash and the full URL of the replacement page.

Does this output use RewriteRule?

It uses Redirect. Conditional or more precise matching calls for a different directive.

Will this line work on every web server?

It uses Apache syntax. Check that the relevant directive is supported and allowed in your site's configuration.

Related guides

Next tool Nginx Redirect Generator