View Single Post

  #1 (permalink)  
Old 09-18-2007
ChronoFish
 
Posts: n/a
Default query apache for rewrite/alias rules

I know the answer is probably "No ", but I'm going to ask anyway.


Is there a way to query Apache for the system path of the file being
requested? (pre-rewrite - I'm not simply asking for a script name
here)


Here is what I want to do and why:

I have written a PHP script that allows a user to surf a Zip file in
the same way that apache serves up directory listings. I have a
rewrite rule that sends the requested file's URI path to my script.
This way anytime the user hits

http://localhost/somepath/myzip.zip

The request is re-written as

/projects/zipView/?file=somepath/myzip.zip&path=


The script returns the contents of the first level directory in the
zip file. If the user clicks on a zipped sub directory, the URL looks
like:

http://localhost/somepath/myzip.zip/contents

and the rewrite rule produces

/projects/zipView/?file=somepath/myzip.zip&path=/contents


All of this works great and as I want it to.

The trick is that there are alias directories. For example "backup"
is mapped to "c:\systemBackup\archive1". The rewrite rule still
works, but it the script tries to grab the wrong directory.


For instance:

http://localhost/backup/2007_09_20/contents.zip

is rewritten

/projects/zipView/?file=backup/2007_09_20/contents.zip&path

However, "backup" is an alias for the directory "c:\systemBackup
\archive1" rather than DOCUMENT_ROOT\backup\


So what I would like is a way to ask Apache for the real directory of
the request /backup.

I could parse the Apache Config file, but that gets tricky once you
start using AliasMatch (regular expressions) not to mention dealing
with multiple included config files.


NOTE: This is a WAMP environment. If this were a LAMP environment
there would be no issue - I would create a symbolic or hard link.

Any thoughts?

Thanks!
CF