Anecdotes from a Linux Systems Administrator. /root

Home About Books Blog Portfolio Archive
17 March 2013

Apache: RedirectMatch

by Alpha01

For the longest time, I’ve been using mod_rewrite for any type of URL redirect that requires any sort of pattern matching.

A few days ago I migrated my Gallery web app from to and I learned that the Redirect directive from mod_alias also has the RedirectMatch directive available, which essentially it’s Redirect with regular expression support.

I was able to easily setup the simple redirect using RedirectMatch instead of using mod_rewrite.

RedirectMatch 301 ^/photos(/)?$
RedirectMatch 301 /photos/(.*)$1
Tags: [ apache ]