On 05/04/07, Sam Carleton [EMAIL PROTECTED] wrote:
On 4/5/07, Graham Dumpleton [EMAIL PROTECTED] wrote:
On 05/04/07, Sam Carleton [EMAIL PROTECTED] wrote:
I have one module that does a few different things.
1: create a index html document of images
2: create a page html document of one image (when user clicks on an
image in the index)
3: Handle the image request that are in the HTML of #1 and #2 and send
out all the images.
Right now I have it all written in PHP, there is a index.php for #1
and #2 and an imageHandler.php for #3. I am trying to understand the
best way to separate this logic within my one module. Someone else
suggested I look at hooking translate_name.
I found my answer to how to determine the location, so I have been
playing with it since my post and when I set the r-filename =
images; and return OK, I get a 403 Forbidden.
Probably because you haven't allowed Apache access to the images
directory. Ie., you still need to have something like:
For starters, the objective is to do away with the PHP code
altogether, I don't think I will do that in the first round, just
replace the image handler, but I am thinking long term;)
The way I have it configured is this:
Location /coolapp
SetHandler mod_my_cool_app
Location
I don't understand your comment about not allowing Apache access to
the images directory, for starters, from the perspective of Apache,
there isn't an images directory, it is elsewhere on the machine that
Apache does not have and will not have access to, it is a security
thing.
But I don't think that is really relevant to the problem. When I type
in /coolapp/images in a browser, my module does get called and the URI
is /coolapp/images, why is it when I simply set the request's filename
(r-filename) to images I get a 403? Apache did not have a problem
with /coolapp/images, why would it have a problem with
/coolapp/images/images? Or does filename mean something different?
In a translate name handler, if you assign to r-filename then the map
to storage phase will still kick in and ensure that Apache has access
to whatever you set r-filename to. Thus, you still need a Directory
directive corresponding to the physical location you set r-filename
to that marks it as accessible. The translate name handler, unless you
also override map to storage handler to work around it, is not really
for setting the target to a virtual resource.
I could try and suggest other approaches, but don't really grasp how
you want all this to work so would just probably going around in
circles. If in the first instance all you want to do is rewrite URLs
to give a different view to the clients, I still suggest you at least
first use mod_rewrite to produce what you want. I know you don't want
to use mod_rewrite in the long run, but being able to see a set of
mod_rewrite rules that demonstrate exactly what you want makes it
easier for anyone to understand as it is clearer than some English
description.
Graham
As I have told others on this wonderful mailing list, my 12+ years of
software development have been in GUI development, not web. I have
always played with web stuff, but this is my first serious web project
and it is for my own new company!
Ultimately I am trying to figure out, within the world of Apache
modules, what is the best way to distinguish between the different
general flow paths in my module. One being to generate HTML and the
other to generate images. To the end user, I would like the URI for
pages to simply be location/ and the URI for the images to be
location/images.
As it stands right now, I am thinking the easiest way is to simply
check to see if the URI is location or location/images inside of
the main handler. Someone else said that the right way to do it is to
do this checking in the translate_name hook. Unless I am able to be
enlightened, which is questionablegrin, I think I will do it the
first way:(
Sam