[emile@iris-advies.com: Re: [PHP-DEV] Adding URI Translation Handlers]

From: Date: Fri, 22 Jun 2001 05:09:02 +0000
Subject: [emile@iris-advies.com: Re: [PHP-DEV] Adding URI Translation Handlers]
Groups: php.dev 
Request: Send a blank email to php-dev+get-57609@lists.php.net to get a copy of this message
Back when the mailing lists were down, I started a discussion about adding a feature to PHP to do URI translating. The brief definition of URI translation is that you get to rewrite URIs dynamically. This is how you you would host, for instance, 10,000 florist home pages: http://florists.ftd.com/rosebowlfloral/ and http://florists.ftd.com/fiveflower/ without having 10,000 directoriies under the server root. In Apache, these would be rewritten to a directory containing the style of page the florist chose, with some extra apache notes to tell you which florist page had been visited. The question I wanted to raise was how to do this. And although it looks like initially a simple task, it generalizes to a few other concepts which Apache + mod_perl has done wonders with. This was the most recent post on the topic, and I wondered if there were other thoughts out there? Failing that, I will probably pursue the approach of building this into the Apache SAPI and letting other web servers follow suit. ----- Forwarded message from Emiliano <emile@iris-advies.com> ----- Date: Thu, 31 May 2001 09:34:00 +0200 (CEST) From: Emiliano <emile@iris-advies.com> To: svanegmond@home.com cc: cvsusers@php.net Subject: Re: [PHP-DEV] Adding URI Translation Handlers Stephen van Egmond wrote: > One thing which I am bumping into is the need to do URI rewriting, kind > of like what mod_perl does. > > I would like to implement this myself in mod_php, and I'm looking for > some advice on the implementation. I considered the following: > > a) Allowing the automatically prepended file (see php's > auto_prepend_file config option) to change $ENV['REQUEST_URI'] before > the script is actually executed. This, intuitively, seems clean, but > would probably happen too late in the request process (it will have > already decided to call the error file). Yep. This would be executed in the response phase, but apache itself would have decided in the translation phase way before that not to handle the request. > b) adding a new config directive that... what? defines a file to be > read which is supposed to define a function? Is eval'ed? The way I see it you have a couple of options: - Use mod_perl, mod_python, mod_tcl(I think) to script a translation handler. - Write a translation handler in C (we do this with Midgard) - Extend mod_php4 to do what mod_perl et al do so you can write handlers in PHP. Conceptually, this is not too hard, but will definately be more work than the other two. You set up the zend engine just like the response phase handler does, set a few relevant variables before you start it (like $ENV['REQUEST_URI'] for example, kick off the script (either be just executing the code, or calling a function therein), then read the relevant variables after the script exits and act on them. You'll be doing this in C. Emile ----- End forwarded message ----- -- ,,, (. .) +--ooO-(_)-Ooo----------------- ----- ---- -- - - - - | The Annotated BeBook: http://bang.dhs.org/be/bebook/

« previous php.dev (#57609) next »