Forum Moderators: phranque

Message Too Old, No Replies

multiple directories in DocumentRoot

is it possible to concatenate them?

         

poochiyama

4:35 pm on Nov 30, 2010 (gmt 0)

10+ Year Member



Hi,

I am trying to establish a development environment in which I would 'book' out a piece of html or php to alter. This would be placed in a development directory. The remaining files in the website would remain in the main directory referenced in the DocumentRoot. I want Apache to check my directory for the altered html before referring to the DocumentRoot. Is it possible to configure Apache to check a concatenated list of folders from which to serve the pages?
Thanks

poochiyama

7:44 pm on Dec 2, 2010 (gmt 0)

10+ Year Member



After many more hours searching I have found the solution in the form of a mod_rewrite. I found exactly what I wanted and am pasting it here
You need to enable mod_rewrite in httpd.conf and the rewrite commands go inside your virtual host config.

Search pages in more than one directory
Description:
Sometimes it is neccessary to let the webserver search for pages in more than one directory. Here MultiViews or other techniques cannot help.
Solution:
We program a explicit ruleset which searches for the files in the directories.
RewriteEngine on

# first try to find it in custom/...
# ...and if found stop and be happy:
RewriteCond /your/docroot/dir1/%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /your/docroot/dir1/$1 [L]


# second try to find it in pub/...
# ...and if found stop and be happy:
RewriteCond /your/docroot/dir2/%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /your/docroot/dir2/$1 [L]


# else go on for other Alias or ScriptAlias directives,
# etc.
RewriteRule ^(.+) - [PT]

jdMorgan

1:45 am on Dec 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The last rule should not be required, as the req-rec will not have changed unless one of the two previous rules has been invoked, in which case, the last rule won't be invoked anyway...

Jim