301 Redirect in Apache with RedirectMatch

By | 2013/09/14

To fine tune performance in Apache, consider using RedirectMatch instead of Rewrite rules. Here are some tips!


Part of mod_alias is something called RedirectMatch. This is a better way to do 301 redirects or other types of redirects than using mod_rewrite for better performance.

One example is, say you wish to redirect non-www to www for your domain. Here is how you do it with mod_alias and RedirectMatch:

RedirectMatch (.*) http://www.example.com$1

You can have Apache issue HTTP 301 as follows:

RedirectMatch 301 (.*) http://www.example.com$1

One thought on “301 Redirect in Apache with RedirectMatch

Leave a Reply

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

Notify me of followup comments via e-mail. You can also subscribe without commenting.