变成:?index/action/one/do/two
复制代码 代码如下:
index.php
--------------
//PARSINGQUERYSTRING
$QS=explode("&",$_SERVER['QUERY_STRING']);
$QS=explode('/',$QS[0]);
//IFModulisUndefinedsetittoindex
if(!$QS[0])$MODUL='index';
else$MODUL=strtolower($QS[0]);
//WEcanmakeaVariable$_QUERY
//foralternative_GET
for($i=1;$i<count($QS);$i+=2)
{
$_QUERY[$NVAR]=$NVAR=$QS[$i];
$$NVAR=$QS[$i+1];
}
//ChecktheModulisexists?
if(!file_exists("modul_directory/{$MODUL}.php"))
$MODUL="index";
####THISISEXAMPLETOIMPLEMENTATIONTHESCRIPT
//LoadTheTemplate
include("template.php");
//LoadTheModule
include("modul_directory/{$MODUL}.php");
//LoadTheFooter
include("footer.php");
?>
wecanaccessthemodulinURLlikethis:
=================================
www.example.com/?forum/topic/20
-itmeanloadthemodulforum.php,andsetthe_QUERY['topic']=20
www.foo.com/?voting/id/54/type/piechart&choice=2
-itmeanloadthemodulvoting.php,andsetthe_QUERY['id']=54and_QUERY['type']='piechart'andset_GET['choice']=2