Elliotte Harold elharo-at-metalab.unc.edu |nyphp dev/internal group use| 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

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.

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?

Typical MVC front controller. A "news" script like /news/index.php gets passed 2007 07 and 05 as params via the front controller, so one script handles all news/year/month/day URLs. Most frameworks provide an MVC front controller.

For me (a search engine optimizer) the core questions come later... how does that MVC front controller handle "exceptions" like:

/news/2007 (missing params) -> should 301 to default URL like /news/2007/01/01/ or throw a 404
/news/dfsrdf/07/06 (invalid year) -> 404 error
/news/ -> either 301 to default URL like /news/2007/01/01/ or throw a 404
/news -> 301 redirect to /news/ ? Too much redirection... either 301 to default URL like /news/2007/01/01/ or throw a 404 /news/2007/07/07 (no trailing slash) -> 301 to trailing slash version /news/2007/07/07/
/news/2007/06/07/whatever (excess params) -> 404

Admittedly, not many PHP coders care about such things. Some actually think flexible dispatching is a feature! Imagine that! ;-)

-=john andrews

--
-------------------------------------------------------------
Your web server traffic log file is the most important source of web business 
information available. Do you know where your logs are right now? Do you know 
who else has access to your log files? When they were last archived? Where 
those archives are? --John Andrews Competitive Webmaster and SEO Blogging at 
http://www.johnon.com

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to