lucy24 - 12:35 am on May 2, 2011 (gmt 0)
First make sure you understand the terminology.
^ without trailing space means "the beginning of the string you're matching"
$ without leading space means "the end of the string you're matching"
--with space, it would mean that the text to be matched has a space in that location
() means "hold on to this text because you'll be using it later"
--the technical term is "capture"
$1, $2 etc. means "insert the part you captured earlier, in the order they were originally captured"
--I don't know how high htaccess lets you count, but you should be safe up to $9
So if all your subdirectories are really named "campaign"-something:
RedirectMatch 301 (http://(?:www\.)?example\.com/)campaign $1allmycampaigns/campaign
If the names start with the same element, you don't need to capture them (with parentheses). You don't actually need to capture the first part (example.com) either; I just did it to save space.
The other approach is
RedirectMatch 301 !example\.com/allmycampaigns/(.+) http://www.example.com/allmycampaigns/$1
RedirectMatch 301 !example\.com/allmycampaigns/(.+) /allmycampaigns/$1
depending on how persnickety your server is.
This version means "if the request doesn't contain the segment 'example.com/allmycampaigns/' then insert 'allmycampaigns/' after 'example.com/' and then put back the rest of the address".