Locating a file in multiple directories

Discussion in 'Apache' started by georgecalm, Nov 17, 2009.

  1. #1
    Hey guys!

    Here's an interesting problem:

    I'm trying to separate some files on a system into a number of packages, and to be able to access them without knowing exactly which package a file is.

    Here's an example: Say, a file /pacakge1/one.htm is in /package1 and /package2/two.htm is in /package2. With the configuration below, I'll be able to access them directly -- http://localhost/one.htm

    
    
    RewriteCond %{DOCUMENT_ROOT}/package1%{REQUEST_URI} -f
    RewriteRule ^(.*) /package1$1 [L]
    
    RewriteCond %{DOCUMENT_ROOT}/package2%{REQUEST_URI} -f
    RewriteRule ^(.*) /package2$1 [L] 
    
    RewriteCond %{DOCUMENT_ROOT}/package3%{REQUEST_URI} -f
    RewriteRule ^(.*) /package3$1 [L]
    
    Code (markup):
    The problem is that I'd like to be able to add more packages, without updating this apache configuration file (and without having to restart apache). I was thinking of something along the lines of:

    
    
    RewriteCond %{DOCUMENT_ROOT}/package(.*)%{REQUEST_URI} -f
    RewriteRule ^(.*) /package%1$1 [L]
    
    Code (markup):
    But, unfortunately, the code above does not work.

    Can you think of a way of solving this problem?

    Regards,
    GC
     
    georgecalm, Nov 17, 2009 IP