http://example.com/urirouter.php/hello/world
或
http://example.com/dir/urirouter.php/hello/world
返回值: hello/world
设置.htaccess后:
http://example.com/hello/world
或
http://example.com/dir/hello/world
返回值: hello/world
$requesturi = trim($_server['request_uri'],'/');$apppath = trim(dirname($_server['script_name']),'/');//获取所在目录$filename = trim(str_replace(dirname($_server['script_name']),'', $_server['script_name']),'/');//获取文件名称echo trim(str_replace($filename,'',trim(str_replace($apppath,'',$requesturi),'/')),'/');
复制代码
rewriteengine onrewritecond %{request_filename} !-frewriterule ^ urirouter.php [qsa,l]
复制代码
