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 https://www.rubysecurity.org/photos to http://photos.antoniobaltazar.com 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(/)?$ http://photos.antoniobaltazar.com
RedirectMatch 301 /photos/(.*) http://photos.antoniobaltazar.com/$1
apache
]