說明:取得此server的url
Demo:www.google.com/a/b/c.html
=>www.google.com
$_SERVER['HTTP_REFERER'] 但HTTP request可以造假
$_SERVER["REQUEST_URI"]
說明:取得完整的參數路徑URI(不含localhost的位置)
Demo:www.google.com/a.html?b=c;
=>a.html?b=c;
$_SERVER['PHP_SELF']
說明:相對路徑
Demo: www.google.com/a/b/c/d.html
=>a/b/c/d.html
1.取得完整的uri
$_SERVER[HTTP_HOST].$_SERVER["REQUEST_URI"]
2.取得到目前的資料夾(含檔名)
$_SERVER[HTTP_HOST] . $_SERVER['PHP_SELF']
3.取得https or http
if(isset($HTTP_SERVER_VARS[HTTPS])){
$_FULL_URL = 'https://'.$SERVER_NAME;
}else{
$_FULL_URL = 'http://'.$SERVER_NAME;
}
沒有留言:
張貼留言