示例:
我有一个网页abc.com/index.php
我想检测用户是否连接到abc.com/index.php/bbdh,abc.com/index.php/bb/saggfd/gjasgd/hsahgd、abc.com/index.php/bb/aggfd/gjas等等,而我的主机上没有这样的页面。
我使用的是php,需要一些方法在不使用.htaccess文件的情况下做到这一点。谢谢你的帮助!
看看$_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参数的更新:
// 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);