RE: how to generate static html pages from dynamic php pages

From: Date: Thu, 09 May 2002 06:20:31 +0000
Subject: RE: how to generate static html pages from dynamic php pages
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-96767@lists.php.net to get a copy of this message
> Yeah, I know about that, too. But with that, the request still goes > through the database and PHP once the variables are exploded() form the > URI. Using the $PATH_INFO trick is great, requires no rewrites, is completely transparent to the user, and makes for nice, clean, search-engine-spiderable URLs. I've used it in two sites now to create pseudo-directory structires. Here's one: http://tmatt.gospelcom.net/column/ 'column' is actually a file that Apache is forced to parse as PHP. It looks at the $PATH_INFO variable to figure out what the user is requesting. It then looks for the existance of a cached version of the file being requested. If it doesn't exist, the file is created from the XML database, stored on the filesystem, and presented to the user. In this case, caching is simply for speed's sake, rather than making search engines happy. This method still allows $QUERY_STRING variables to be properly passed to the URL, also, if you want to do that. > What I'm talking about is a user goes to a nonexistent page, > www.domain.com/products/1234 and should get a 404 error. Instead, your > 404 page looks in the database for product 1234 and sees if it exists. > If it does, it writes the file products/1234/index.html with the data > from the database. Now, when the next person follows your link to > www.domain.com/products/1234, they get your html page, instead of > hitting PHP and the database, thus saving you some resources... This is cool, but I would be really hesitant to make my 404 page serve up actual real content, even if it's only the first time the link is hit. For the sake of search engines that might ignore links that return a 404 error (regardless of the content at that page), I would want to make sure my content returns a valid HTTP status code, so that search engines know that the content is okay to index. Now, I don't know a whole ton about search engines, so maybe they happily ignore 404 errors. But I really doubt that, since there's no point in indexing a page that isn't there... The $PATH_INFO trick can do exactly what you describe above -- just make Apache parse a file called 'products' as PHP, and the rest falls into place. -- [ joel boonstra | jboonstra@gospelcom.net ]

« previous php.general (#96767) next »