You should never use mod_rewrite directives inside a <Location>
wrapper. The docs explicitly warn against this.
However, to simply redirect "old" to "new" you don't necessarily need mod_rewrite. A simple mod_alias Redirect
directive would suffice. Although a possible exception to this is if you are already using mod_rewrite for other redirects/rewrites.
For example:
Redirect 302 /old/ /new/
The Redirect
directive is prefix-matching, and everything after the match is copied to the end of the target URL. So, the above will redirect /old/<anything>
to /new/<anything>
.
Or with mod_rewrite:
RewriteEngine On
RewriteRule ^/?old/(.*) /new/$1 [R=302,L]
R
(without an explicit response code) is the same as R=302
, however, it is often better to be explicit.