jdMorgan - 12:34 am on Jan 25, 2011 (gmt 0)
Do not mix the use of mod_alias Redirect and RedirectMatch directives with mod_rewrite RewritRule directives. At best, this makes the order of execution unpredictable, and at worst, it results in incorrect execution and in the exposure of internal filepaths as URLs.
I basically just want to add a redirect rule which redirects any URL-path like this
to a URL like this
Is this possible?
Yes, and it can even be done quite efficiently as well:
RewriteRule ^([^/]+/)*79-publications$ http://www.example.com/publications [R=301,L]
The first bit of regex just says, "match as many directory-levels as you like" and allows the URL-path to be matched in a single left-to right pass.
It is marginally faster than the "79-publications$" pattern without a start-anchor because it identifies the "boundaries" following slashes where "79-publications" should be matched, and it also might prevent an unexpected match on a request for "/<something-anything>/1879-publications" as well.