You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Aaron Johnson <so...@gina.net> on 2000/12/11 07:06:15 UTC

File name conversion

Is there a module that allows you to translate the file name into
something else, but keeps the requested filename in an enviroment
variable or other location?

For instance, say I request
http://www.mydomain.com/myfile.html
That works fine and is a real file.
Now I want to request:
http://www.mydomain.com/abc_myfile.html

abc_myfile.html is not a real file.  I need to be able to access the
real name via $r->filename, but have something telling me the original
request had abc_ as a prefix.  I need to use the prefix to set options
in the page under Apache::ASP.

If I was going to stay on an OS that would support symlinks I would just
use symlinks for the different names and all would be fine, but for NT
this is not doable, or at least doesn't seem to be.

I see where I can get at the $r->filename value and modify it, but I
hope to be able to do the translation before Apache::ASP gets a hold of
it so I don't have to modify the Apache::ASP script.

Can I chain the handlers?
Does altering the $r->filename alter the %ENV in anyway?


Aaron Johnson




Re: File name conversion

Posted by Aaron Johnson <so...@gina.net>.
That is just what I was looking for.

I just modified the $r->filename and left $r->uri untouched.

10 lines of code and I have it doing exactly what I needed and Apache::ASP reads
the correct file.
I still have the $ENV{REQUEST_URI} to check for the orginal name requested, there
by allow me to set options based on it.

I see now it is in the Guide as well at:
http://thingy.kcilink.com/modperlguide/snippets/PerlTransHandler_example.html

Not knowing what I needed to do was called (or what phase it was best handled) was
the root of my problem.

Thanks!

Aaron Johnson

darren chamberlain wrote:

> Hi Aaron,
>
> Check out the section titled "Using a Translation Handler to Change the
> URI" in Chapter 7 of the Eagle book, at
> http://www.modperl.com/book/chapters/ch7.html#Using_a_Translation_Handler_to_C.
>
> Aaron Johnson (solution@gina.net) said something to this effect:
> > Is there a module that allows you to translate the file name into
> > something else, but keeps the requested filename in an enviroment
> > variable or other location?
>
> (darren)
>
> --
> So far as a man thinks, he is free.


Re: File name conversion

Posted by darren chamberlain <da...@boston.com>.
Hi Aaron,

Check out the section titled "Using a Translation Handler to Change the
URI" in Chapter 7 of the Eagle book, at
http://www.modperl.com/book/chapters/ch7.html#Using_a_Translation_Handler_to_C.

Aaron Johnson (solution@gina.net) said something to this effect:
> Is there a module that allows you to translate the file name into
> something else, but keeps the requested filename in an enviroment
> variable or other location?

(darren)

-- 
So far as a man thinks, he is free.