Image

Imagezerozephr wrote in Imagephp_dev

Looking Static

Imagehalkeye posted a few weeks ago looking for a way to create the illusion of static files with php. I just wanted to share my personal experience with a project just nearly wrapped up.

Basically we had a bunch of php files that called data from MySQL. Before, we passed variables in the URL such as blah.php?id=1. Now, we set up several symbolic links such as blah -> blah.php and used that as a "directory" of sorts. We then set up in the script a preg_match function to strip out the needed variable such as blah/article_1.html using $_SERVER['PATH_INFO']. Ala:

if (preg_match("/^\/article_(\d+)\.html$/", $_SERVER['PATH_INFO'], $matches)) {
$id = $matches[1];
}

Finally we added to a .htaccess file:

DefaultType application/x-httpd-php

I'm just a beginner, and it's great to see how much regular expressions can do.