Redirect subfolder but individually redirect files within it in .htaccess

In my .htaccess file I have:

redirect 301 /blog                          
redirect 301 /blog/2009/06/okay-to-kiss/

I got rid of the blog section of my site so I want to redirect the main blog folder to my site's home page. I also moved some of the blog posts into other areas of my site so I want to redirect those specific blog posts to their new locations. Unfortunately, redirecting the blog folder causes problems with the specific blog post redirects. The line:

redirect 301 /blog/2009/06/okay-to-kiss/

ends up redirecting visitors to instead of

How can I fix this?

Ben Cunningham
Who is Participating?
Steve BinkCommented:
Remember that the Redirect directive's first parameter is a wildcard to match to the *beginning* of the URL.  When you put "redirect 301 /blog", any URL starting with /blog will have "/blog" replaced with your target.

One solution is to list the most specific redirection first, thereby limiting the application of the more general redirection.

Another solution would be to use mod_rewrite instead, which gives you much greater control.  It would be overkill in this scenario, I think.
webstuck5Author Commented:
I thought I had tried putting the general redirection after the specific reduction and it didn't work. It seems to be working now.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.