query apache for rewrite/alias rules

This is a discussion on query apache for rewrite/alias rules within the Apache Web Server forums, part of the Web Server and Related Forums category; I know the answer is probably "No ", but I'm going to ask anyway. Is there a way ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #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

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

"ChronoFish" <deja@chronofish.com> schreef in bericht
news:1190147633.150068.158140@n39g2000hsh.googlegr oups.com...
> 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
>
> The trick is that there are alias directories. For example "backup"
> is mapped to "c:\systemBackup\archive1". The rewrite rule still
> works,

BEFORE the alias kicked in ...

> but it the script tries to grab the wrong directory.

.... THUS the script is misguided

> 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\
>

When mod_alias and mod_rewrite interfere mostly the [PT] flag will save your
day ... guts feeling not this time :|

> 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.

http://www.microsoft.com/technet/sys.../Junction.mspx
Windows 2000 and higher supports directory symbolic links, where a directory
serves as a symbolic link to another directory on the computer. ...

You may try your luck with the utility downloadable at the same page.

HansH


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

On Sep 18, 4:33 pm, ChronoFish <d...@chronofish.com> wrote:
> 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


Here is the answer to my question:

You can pass %{REQUEST_URI} through the rewrite rule which gives the
file-system target. Made a tiny change in my script to accommodate
and everything is good.

Thanks,
CF

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:59 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0