Redirect and RedirectMatch

Redirect, RedirectMatch and When mod_alias Is Enough

Redirect status URL-path URL matches a path prefix at whole segments and appends the rest of the path and the query string to the target. RedirectMatch takes a regular expression and appends only the query string, so you rebuild the path from captures. Both need AllowOverride FileInfo:

Five kinds of move with mod_aliasApache config
# /var/www/example/.htaccess: fixed moves with mod_alias alone
# Needs: mod_alias (enabled by default); AllowOverride FileInfo
Redirect 301 /pricing.html /plans
Redirect permanent /docs/v1 /docs/v2
RedirectMatch 301 ^/blog/\d{4}/\d{2}/([a-z0-9-]+)\.html$ /articles/$1
Redirect 308 /api/v1 https://api.example.com/v1
Redirect gone /summer-sale
Output
/pricing.html?ref=mail          301 http://example.com/plans?ref=mail
/docs/v1/install?os=linux       301 http://example.com/docs/v2/install?os=linux
/docs/v10                       404 
/blog/2019/05/hello-world.html  301 http://example.com/articles/hello-world
/api/v1/orders                  308 https://api.example.com/v1/orders
/summer-sale                    410

Line 4 moved a whole tree but left /docs/v10 alone, because v1 matches whole segments only. Line 6 uses 308 because API clients send POST: RFC 9110 lets a client turn it into a GET after a 301 or 302, never after a 307 or 308, and Google weighs 308 like 301. Line 7 answers 410 Gone with no target; Google drops a 410 exactly like a 404, but people learn the removal was deliberate. mod_alias is enough when the path alone decides the move; to read the query string or test for a file, use mod_rewrite, but never on the same URLs (Rewrite, Redirect or Alias).