Forum Moderators: phranque

Message Too Old, No Replies

apache 2, mod rewrite, .htaccess and directory inheritance

how to change inheritance behaviour, if possible

         

janharders

8:56 pm on Dec 17, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


Hey everybody,

I guess it's documentated somewhere, I just cannot seem to find it.
Here's the setup:
document root is /var/www
there is a directory /var/www/test
in /var/www/test/.htaccess, there is
RewriteEngine On
RewriteRule example http:/[smilestopper]/www.example.com/

in /var/www/.htaccess, there is
RewriteEngine On
RewriteRule another http://www2.example.com/

Now if a request on /test/example is made, a redirect to www.example.com kicks in, as expected.
a request to /test/another does not, however, result in a redirect to www2.exmaple.com - that is, unless there is nothing in /var/www/test/.htaccess about mod_rewrite.
I understand the process is like this:
.htaccess are checked for every parent directory of the directory that is valid for the current request.
they are traversed in reverse order by mod_rewrite until one is found that contains rules (that is, if /var/www/test/.htaccess contains rules, they're applied, else /var/www/.htaccess will be checked, untill /.htaccess is reached). Can anyone confirm that or correct me?
My hopes were, before I tested it, to have mod_rewrite continue with the next .htaccess untill a [L] rule is found or there aren't any .htaccess files left. Does anyone know of a way to achieve that without heavily hacking apache or mod_rewrite?

Thanks for any insights.

jdMorgan

4:10 am on Dec 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand the problem, you need to set
RewriteOptions inherit
-- It sounds like it's not set in your server config.

Jim

janharders

6:24 am on Dec 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wow, thanks. I cannot believe I missed that. Sometimes I should probably just write down my questions so others will understand it, then search for what I wrote.

thanks again, that does exactly what I wished to accomplish.