up vote 0 down vote favorite
share [g+] share [fb]

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.

link|improve this question

RewriteCond %{blog_map:$1} instead of RewriteCond ${blog_map:$1} Is it a typo in the referenced blogpost or in your post or is it correct both ways? – axk Oct 8 '09 at 20:31
No, it was a typo in the blogpost. And thus in my config. Thanks for spotting that, I should have picked that up :) – mikl Oct 8 '09 at 20:45
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.