-1
我想用變量$_SERVER ["REQUEST_URI"]
讓我安裝服務器的URL,但我得到的404錯誤:
例如:
www.example.com/dir/
我需要一個路徑,把它作爲index.php
和從那裏我採取我需要的路線,但對於這個錯誤,我無法獲得我需要的值。
我想用變量$_SERVER ["REQUEST_URI"]
讓我安裝服務器的URL,但我得到的404錯誤:
例如:
www.example.com/dir/
我需要一個路徑,把它作爲index.php
和從那裏我採取我需要的路線,但對於這個錯誤,我無法獲得我需要的值。
您可以通過這個做吧..
//get the url
$myaddress = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//parse the url
$parse_url = parse_url($address);
//use explode to get the path
$paths = explode('/', ltrim($parse_url['path'], '/'));
print_r($paths);
// or get the first path
echo $paths['0'];
您現在有路徑..