From 54639a391b8f628a30e6d75f2fee021f4ef767a1 Mon Sep 17 00:00:00 2001 From: markjaquith Date: Fri, 17 Aug 2007 03:32:19 +0000 Subject: [PATCH] Set REQUEST_URI for IIS in more situations. props snakefoot. fixes #3514 git-svn-id: http://svn.automattic.com/wordpress/trunk@5889 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-settings.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/wp-settings.php b/wp-settings.php index faedd3718..9dd4269c0 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -27,11 +27,26 @@ if ( ! isset($blog_id) ) // Fix for IIS, which doesn't set REQUEST_URI if ( empty( $_SERVER['REQUEST_URI'] ) ) { - $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI? - // 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']; + // 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 { + // If root then simulate that no script-name was specified + if (empty($_SERVER['PATH_INFO'])) + $_SERVER['REQUEST_URI'] = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')) . '/'; + 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']; + } } }