// Fix for IIS, which doesn't set REQUEST_URI
if ( empty( $_SERVER['REQUEST_URI'] ) ) {

// IIS Mod-Rewrite
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
}
// IIS Isapi_Rewrite
else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
else
{
// Use ORIG_PATH_INFO if there is no PATH_INFO
if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];

// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
if ( isset($_SERVER['PATH_INFO']) ) {
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
else
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
}

// Append the query string if it exists and isn't null
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}
}

或者这里 看里面的程序是这样写的
可以参考这里来设置

* Instructions: http://neosmart.net/blog/2006/100-apache-compliant-request_uri-for-iis-and-windows/
* Support: http://neosmart.net/forums/forumdisplay.php?f=17
* Product URI: http://neosmart.net/dl.php?id=7
/*
* REQUEST_URI for IIS Servers
* Version: 1.1
* Guaranteed to provide Apache-compliant $_SERVER['REQUEST_URI'] variables
* Please see full documentation at

* Copyright NeoSmart Technologies 2006-2008
* Code is released under the LGPL and maybe used for all private and public code

* Instructions: http://neosmart.net/blog/2006/100-apache-compliant-request_uri-for-iis-and-windows/
* Support: http://neosmart.net/forums/forumdisplay.php?f=17
* Product URI: http://neosmart.net/dl.php?id=7
*/

//This file should be located in the same directory as php.exe or php5isapi.dll

//ISAPI_Rewrite 3.x
if (isset($_SERVER['HTTP_X_REWRITE_URL'])){
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
//ISAPI_Rewrite 2.x w/ HTTPD.INI configuration
else if (isset($_SERVER['HTTP_REQUEST_URI'])){
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_REQUEST_URI'];
//Good to go!
}
//ISAPI_Rewrite isn't installed or not configured
else{
//Someone didn't follow the instructions!
if(isset($_SERVER['SCRIPT_NAME']))
$_SERVER['HTTP_REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
else
$_SERVER['HTTP_REQUEST_URI'] = $_SERVER['PHP_SELF'];
if($_SERVER['QUERY_STRING']){
$_SERVER['HTTP_REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
//WARNING: This is a workaround!
//For guaranteed compatibility, HTTP_REQUEST_URI or HTTP_X_REWRITE_URL *MUST* be defined!
//See product documentation for instructions!
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_REQUEST_URI'];
}

, ,
Trackback

5 comments 至今

  1. %blog_comment%

  2. this contact form

    iis下不支持$_SERVER[‘REQUEST_URI’]的解决办法 互联网观察 福贵的窝窝 福贵的窝窝

  3. 中国水泵

    iis下不支持$_SERVER[‘REQUEST_URI’]的解决办法 互联网观察 福贵的窝窝 福贵的窝窝

  4. 俄羅斯海關

    iis下不支持$_SERVER[‘REQUEST_URI’]的解决办法 互联网观察 福贵的窝窝 福贵的窝窝

  5. ѡhoah this webⅼog is matnificent i lov reading your articlеs.
    Stay up the good work! You recogniᴢe, a lоtt of persоns aгe hunting гound for this information, you could help them greatly.

添加评论