$_SERVER["REQUEST_URI"]是在Apache下是可用的,但在iis下是不可用的

<?php
// 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'];
		}
	}
}

http://leepiao.blog.163.com/blog/static/485031302011282435689/


http://www.jianghuimin.com/program/php/1286.html


http://www.9iyuedu.com/post-282.html

你可能感兴趣的:(apache,String,server,query,Path,IIS)