NYCPHP Meetup

[nycphp-talk] Many pages: one script

David Krings ramons at gmx.net
Mon Aug 6 19:28:09 EDT 2007


Elliotte Harold wrote:
> Here's a simple example: a news site backed by a database. URLs like
> 
> http://www.example.com/news/2007/07/05
> http://www.example.com/news/2007/07/06
> http://www.example.com/news/2007/07/07
> http://www.example.com/news/2007/07/08
> ...
> 
> return pages which contain that day's headlines extracted from the 
> database.

Are those dates consecutive? Means, is there a newspage for each day? If 
yes, then this is trivial. Still trivial if they are excluding sundays 
or such.

> 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 services.)
> 
> 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?

Yes, a db table and header("Location:  ") redirects that get stuffed 
from what the table query returns, plus one redirect for the case the 
required resource isn't found.

Unless I am entirely dense, this is what the other posts point to the 
whole time.

David





More information about the talk mailing list