Redirect entire directory to one page w/htaccess

Is there a way to redirect any pages in a directory to just one page using a redirect 301 or other rule in an htaccess file?

I tried to do something like this but it didn’t work:

redirect 301 /direc/ http://www.example.com/catchallpage.php

fs,

The reason that doesn’t work is that Redirect is trying to forward to a similarly named page at the redirect “directory.”

Personally, I’d use mod_rewrite with:

RewriteRule ^/?direc/ catchallpage.php [R=301,L]

Regards,

DK

Can that rule be added to an htaccess file or does it have to go right into the Apache config file? In this case I don’t have access to the Apache files (shared hosting) and it did not seem to work when I added it to the htaccess.

fs,

It was designed to go into .htaccess (most people are on a shared host) but you’ll need to ensure that you have mod_rewrite enabled AND that .htaccess hasn’t been renamed or prohibited to you (hosts can do that and some do!).

If you need directions on how to be sure, visit the “Article” in my signature - it’s at the beginning.

Regards,

DK