From 27c26dcb8ea985e44144f30179f64f1f82579ad3 Mon Sep 17 00:00:00 2001 From: Mark Jaquith 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: https://develop.svn.wordpress.org/trunk@5889 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-settings.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/wp-settings.php b/wp-settings.php index faedd3718f..9dd4269c03 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']; + } } }