[nycphp-talk] Many pages: one script

Dell Sala dell at
Sun Aug 5 14:26:41 EDT 2007

On Aug 5, 2007, at 1:42 PM, Elliotte Harold wrote:

> For the system I'm designing that simply won't work. In Java  
> servlet environments it's relatively trivial to map one servlet to  
> an entire directory structure, so that it handles all requests for  
> all pages within that hierarchy.
> Is there any *reasonable* way to do this in PHP?

Here's an example of how to do it without using mod_rewrite. The  
basic idea is to build a front-controller that parses the $_SERVER 
['PATH_INFO'] variable, and delegates the request appropriately for  
your application.

* gotcha: I've had problems getting this to work when php is  
installed as a CGI.

> The only way I've ever seen is what WordPress does: use mod_rewrite  
> [...] I am impressed by this hack, but it's way too kludgy for me  
> to be comfortable with.

I agree, I'm not fond of the mod_rewrite solution. However, I've  
found that to be the only reliable method when php is running as a CGI.

-- Dell

More information about the talk mailing list