[nycphp-talk] Many pages: one script

csnyder chsnyder at
Mon Aug 6 15:07:51 EDT 2007

On 8/5/07, Elliotte Harold <elharo at> wrote:
> Surely by now there's a better way? How do I overcome the one file per
> URL assumption that PHP makes?

I've tried at least four different ways around this over the years,
and I use mod_rewrite for everything but trivial apps.

Here are the ways I'm aware of:

1) Use ErrorDocument directive to pass 404s to a php script

2) Use Action and AddHandler directives

3) Use Multiviews option so that
/index.php/path/to/some/virtual/resource resolves to index.php

4) Use mod_rewrite to send all requests to the same script

The only one I _wouldn't ever_ try again is the ErrorDocument method,
because the $_SERVER environment that you end up with (and which is
crucial to determining what was actually requested) is not what you'd

Mutliviews is always tricky for me, for some reason. I have a hard
time getting it to work with my base server config. Also, I don't like
to have the script name in every request.

Rewrite has proven to be the most flexible and (long-term) easiest
solution for me. But the Action/Handler method doesn't require any
extra extensions. I see it used by other projects, notably Trac.

Chris Snyder

More information about the talk mailing list