The global variable $_SERVER['PATH_INFO'] in PHP is a very useful parameter. Many CMS systems use this parameter when beautifying their URLs.
For the following URL:
http://www.test.com/index.php/foo/bar.html?c=index&m=search
We can get $_SERVER['PATH_INFO'] = '/foo/bar.html', and at this time $_SERVER['QUERY_STRING'] = 'c=index&m=search';
Usually, when we first start writing PHP programs, we will use URLs such as: http://www.test.com/index.php?c=search&m=main. This kind of URL not only looks very strange, but also It is also very unfriendly to search engines. Many search engines will ignore the content after the Query String when indexing. Although Google will not ignore the Query String, it will give a relatively high PR value to other pages that do not contain the Query String.
The following is a very simple code to parse PATH_INFO:
if( !isset( $_SERVER['PATH_INFO'] ) ){ $pathinfo = 'default'; }else{ $pathinfo = explode('/', $_SERVER['PATH_INFO']); } if( is_array($pathinfo) AND !empty($pathinfo) ){ $page = $pathinfo[1]; }else{ $page = ' a.php'; } require "$page.php"; //Bang Ke Home LieHuo.NeT ?>
|