php to achieve pseudo-static
Another is the pseudo-static mode, that is, users and search engines to see the static HTML page suffix, but in fact it is a dynamic program, but somehow disguised.
There are two ways to do this:
The first is through the web server, URL rewrite link static, the following example to explain the way to achieve it. For users with server configuration permissions, it is recommended to use apache's mod_rewrite module, assuming that the mod_rewrite module is already installed. Open the apache configuration file, find the appropriate host part, add the following code:
rewriteengine on
rewriterule ^ / abc / ([az] +) / ([0-9] +). html $ /abc.php?action=$1&id=$2
Then execute the service httpd reload in the shell, so that apache reload configuration just fine.
But for most of us, the only thing we buy is space, and there's no way to change apache's configuration file. Is there any way? No, of course there is a way, first of all, we go to the root of our space (like public_html) and then create a file named .htaccess. The basic content of this document is as follows:
rewriteengine on
rewritebase /
rewriterule ^ post / ([0-9] +). htm read.php? 1
rewriterule ^ post / ([0-9] +) _ ([0-9] +). htm read.php? 1 & page = 2
rewriterule ^ post / ([0-9] +) _ ([0-9] +) _ ([0-9] +). htm read.php? 1 & page = 2 & = 3
php program written
function mod_rewrite () {
if (isset ($ _server ['path_info'])) {
$ url = substr ($ _server ['path_info'], 1);
$ url = explode ('/', $ url);
foreach ($ url as $ key => $ value) {
if ($ key% 2! = 1) {
if ($ value! = '') $ _get [$ value] = $ url [$ key + 1];
$ querystring [] = $ value. '='. $ url [$ key + 1];
}
}
$ _server ['query_string'] = implode ("&", $ querystring);
$ _server ['php_self'] = substr ($ _server ['php_self']
, 0, strpos ($ _server ['php_self'], '.php') + 4);
$ _server ['request_uri'] = $ _server ['php_self']
. '?'. $ _server ['query_string'];
}
}