Hi aarya, :cheesy:
The question really is why you want to convert the php pages to static html files, and if it is necessary.
1) URL rewriting: The link you posted, though with an html extension, may actually be parsed by php. If this is the case, that means they are more concerned about Search Engine Friendly (SEF) urls than anything else.
2) PHP Cache: On the other hand they may very well be static html pages. If they are, then they may also be concerned about their server processing, and faster generation of the html page. (php will be slower to generate an html page).
In the case of this forum, (the link you posted above), it is most likely a SEF addon for VBulletin (this forum software) such as found here: http://www.vbulletin.org/forum/showthread.php?t=63314
If you're websites pages are very dynamic, like the real estate search listings page, you would probably want to use url rewriting (1).
Im not an expert, so I only know of the Apache Server methods of doing this.
You can rewrite the urls using mod_rewrite. Which is an apache module.
This is quite long to discuss here, but you can find alot of resources on the web.
Such as: http://www.sitepoint.com/article/search-engine-friendly-urls
If your php page content does not change frequently, but you have alot of hits, and your server is slowing down, you can use a cache system (2).
A chache system, simple creates static html pages out of the php pages you have (but is more complicated then that).
Its discussed here: http://www.zend.com/zend/art/scriptcaching.php
What you can do is search the web for ready made open source scripts that do the job. They take care of a lot of problems that arise when you want to use these methods. (and automate alot of things, like changing all your links to point to the static files).
If you just want to know how to create an static html file from php, and are not concerned about the implementation. Its really simple:
[PHP]
// creates a local version of any url contents as html files
function cache_url($url, $cache_name, $cache_path = 'cache/') {
// this is simple the path to store the html file
$cache_abs_path = $cache_path.$cache_name;
// this opens an http connection to the url of your webpage
// search fopen at php.net
// you must supply a http path to this, so that we use the http wrapper and return only html
if (!$file = @fopen($url, 'r')) {
echo ('could not open the url: '.$url);
return false;
}
// this opens a file pointer to the html file you are saving too
// if the file doesnt exist, then it will attempt to create a new one
// you need the directory to have write permissions for the script
// chmod 777 (this can be done via ftp, or a web control panel, or php)
if (!$cache_file = @fopen($cache_abs_path, 'w+')) {
echo ('could not open the cache: '.$cache_abs_path.' for writing.');
return false;
}
// here we read the contents of the webpage
while($read = fread($file, '2082')) {
$content .= $read;
// we write the content of our webpage to the html file
if (!@fwrite($cache_file, $read)) {
echo ('error writing to cache: '.$cache_file.' for writing.');
return false;
}
}
// call the function like this
// here you will create a html page page_43.html in your pages directory.
// if you have the script in your webroot (http://mysite.com/) then the new page will be http://mysite.com/pages/page_43.html)
cache_url('http://mysite.com/page.php?id=43', 'page_43.html', 'pages');
[/PHP]
Good Luck.
www.digital-ether.com