示例:
我有一个网页abc.com/index.php
我想检测用户是否连接到 abc.com/index.php/bbdh , abc.com/index.php/bb/saggfd/gjasgd/hsahgd , abc.com/index.php/bb/saggfd/gjas ,等等,没有网页就像我主人那样。
我正在使用php并且需要一些方法来执行此操作而不使用.htaccess文件。 谢谢你的帮助!
答案 0 :(得分:2)
查看$_SERVER['REQUEST_URI']
,您可以在此处访问所需的所有内容。例如。为:
abc.com/index.php/bb/saggfd/gjas
它将是:
/index.php/bb/saggfd/gjas
使用以下内容删除/index.php
echo substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
你已经确定了。
更新:
// get the full request uri
$requestUri = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
// let php parse that url (though it's just a part of the full url)
$chunks = parse_url($requestUri);
// let php parse the query string
parse_str(isset($chunks['query']) ? $chunks['query'] : '', $chunks['query']);
// debug output
print_r($chunks);