I'm trying to set up a bunch of redirects based on this formula, but so far I haven't been able to make it work.
I've been messing with it for hours, but my current setup looks like this:
<IfModule mod_rewrite.c>
RewriteLog /var/log/httpd-rewrite.log
RewriteLogLevel 9 # Just for debugging
RewriteEngine on
RewriteMap blog_map txt:/path/to/blog_map.txt
RewriteCond %{blog_map:$1} >""
RewriteRule ^(/blog/.+)$ ${blog_map:$1} [R=301,L]
</IfModule>
This should supposedly work, but when I try to hit one of the URLs in the map, I get this in my log (sans timestamp and all that):
[initial] (2) init rewrite engine with requested uri /blog/2008/a_git_mirror_for_drupal_cvs
[initial] (3) applying pattern '^(/blog/.+)$' to uri '/blog/2008/a_git_mirror_for_drupal_cvs'
[initial] (4) RewriteCond: input='' pattern='>""' => not-matched
[initial] (1) pass through /blog/2008/a_git_mirror_for_drupal_cvs
[subreq] (2) init rewrite engine with requested uri /blog/2008/a_git_mirror_for_drupal_cvs
[subreq] (1) pass through /blog/2008/a_git_mirror_for_drupal_cvs
The line from my blog_map.txt that matches this URL looks like this:
/blog/2008/a_git_mirror_for_drupal_cvs /blog/2008/feb/19/a_git_mirror_for_drupal_cvs/ # Node ID: 98
I've tried several other scenarios, but so far I've only been able to accomplish either
- Redirect matching the current correct URL as well, causing a redirect loop.
- Redirection not working.
Can anyone help me get this right?
This is with Apache/2.2.13 (FreeBSD) if that makes any difference.