[nycphp-talk] Many pages: one script
ken at secdat.com
Mon Aug 6 20:27:48 EDT 2007
Elliotte Harold wrote:
> Kenneth Downs wrote:
>> Again, I'm not clear on what you are trying to serve. We probably
>> have to back up to the beginning and erase the assumption that PHP
>> has a one-to-one correspondence between a URL (or page) and a PHP
>> file. Having erased that, we have to ask what kind of content you
>> are trying to serve, then we have to look at PHP examples.
> Here's a simple example: a news site backed by a database. URLs like
> return pages which contain that day's headlines extracted from the
> One script, no more, must handle all dates. (I don't really care if
> there are 2 or 3 scripts, but I do not want to have to write a
> separate page for each URL. The number of PHP scripts must be finite
> and fixed. It should not increase with the number of URLs the script
> The only way I've ever seen this done in PHP is by using mod_rewrite,
> though they're a couple of other interesting suggestions in the thread
> I need to explore further. Do you have a suggestion?
The way I actually did it in Andromeda was to use an .htaccess (though
you could put in Apache's config of course) with these lines given to me
by somebody on this list:
Now a file named "news" (a php file w/o the extension) is your universal
dispatcher. The "news" file splits the query string on slash and
determines which row to pull from the database.
The "news" file can also make sure subscribers are paid up, stuff like
that. In fact, it can load your entire framework and do anything you want.
Secure Data Software, Inc.
631-689-7200 Fax: 631-689-0527
More information about the talk