Stubborn mod_rewrite problem



I’ve moved a WordPress blog from to (the root directory). The blog itself transferred without a hitch, but I’m trying to write an .htaccess file to put at that keeps all old links to the blog’s posts working. The idea is that redirects to The current version, saved at, reads this way in its entirety:

Options +FollowSymLinks RewriteEngine On RewriteBase /blog/ RewriteRule (.*)$1 [R=301,NC,L] And that works for everything except one address: <-- without the trailing slash. That URL will redirect to this:

As far as I can tell, when the URI lacks a trailing slash, the RewriteBase doesn’t work right, and it somehow interprets $1 as the full filesystem path of the directory, even though I’m not telling mod_rewrite to do that anywhere. I think I understand the problem, but no matter what I try–and I’ve tried literally dozens of things, for hours–I can’t get it to work. Can someone please help me?


Update: Among the many things I’ve tried, here is the most recent. I removed and created, which consists only of this:

RedirectMatch 301 ^/blog(.*)$1And that also works for everything except sans trailing slash. Now, that one URL redirects to this:

This is so awesome! It appears that when the trailing slash is left off, mod_rewrite decides that (.*) is a hugely expanded combination of %{HTTP_HOST} and %{REQUEST_FILENAME}. Is this because we’re running PHP as a CGI? Are there environment variables I have to set? I’m very much at sea here. Thank you!