Although I have been developing web pages for a few years (HTML, PHP, MYSQL), I am a novice using mod_rewrite. I have read several tutorials and many seem contradictory. I may be going about this all wrong so I am seeking guidance from someone with experience in this area.

I am having trouble with a redirect in my top level domain if a subdirectory also contains a .htaccess file.

To help explain, here is my directory structure.

"www.domain1.com" points to directory /public_html

"www.domain2.com" points to directory /public_html/domain2

My goal is to keep people from directly accessing directory domain2 using "http://www.domain1.com/domain2/" I want them to access it only by "http://www.domain2.com/"

Here is the .htaccess file that I have placed in directory /public_html

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain1\.com$
RewriteRule ^domain2\/?(.*)$  - [F]
If I do not have a .htaccess file in directory /public_html/domain2, then this works fine and properly displays the Forbidden error.

In directory /public_html/domain2 I also have the following .htaccess file:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain2\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain2\.com$
RewriteRule ^forums\/?(.*)$ http://forums.domain2.com/$1 [R=301,L]
I want users to be sent to "http://forums.domain2.com" when they enter "http://www.domain2.com/forums/" (this redirection works fine)

The problem I am encountering is when directory /public_html/domain2 contains a .htaccess file, then the rewrite rule in the .htaccess file in directory /public_html for domain "www.domain1.com" does not work (the page on the /domain2 directory is displayed when the desired result is to display the forbidden error).

I am running Apache 2.2.14.

Any assistance will be appreciated.

Steve