您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

URI的获取,兼容文件存在于子目录

2026/2/8 3:47:36发布15次查看
据说$_server['request_uri']只能在apache才可以用(没测试过),所以只兼容apache。
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]
复制代码
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product