Some 3,000 Apache redirection rules are getting scrapped by a client (not a bad thing), and I wanted to make sure I had a note before that happened. All 3,000 rules are all variations on the following few types of redirection rule.

Redirecting a branching tree of URLs using mod_alias, a many to many redirection, this is a nice simple one liner. Example redirects:

  • redirects to
  • redirects to
Redirect permanent /2010/

A redirect to outside the current domain which stops further rewrite rule processing, a many to many redirection, using mod_rewrite here rather than mod_alias “Redirect permanent” it allows us to stop executing further rewrite rules if we match one of these; e.g. if there are rewrite rules further down which we specifically need to avoid.

This rule redirects everything under to, same example redirects as above.

RewriteCond %{REQUEST_URI} ^/whatever(.*)? RewriteRule ^whatever [R=permanent,L]

Collapse a branching tree of URLs into one URL using mod_rewrite, here’s some examples:

  • redirects to
  • redirects to
  • redirects to
RewriteRule ^whatever.* [R=permanent,L]

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.