$HTTP_SERVER_VARS 变量就可以得到 前面的部分。
其实 PHP 手册上面就有。 可以去 http://www.php.net/  
下载一分看看   chm 格式的 方便阅读和搜索。<?
if(isset($HTTP_SERVER_VARS[HTTPS]))
{
 $_FULL_URL = 'https://'.$SERVER_NAME;
}
else
{
 $_FULL_URL = 'http://'.$SERVER_NAME;
}
// define the variable to make it accessable throughout your script$_FULL_URL .= $PHP_SELF;define('_FULL_URL',$_FULL_URL);// echo the results
echo _FULL_URL;// returns http://www.yourdomain.com/yourdir/youpage?>测试通过