Make WordPress Core

Ticket #3514: wp-setting.diff

File wp-setting.diff, 1.4 KB (added by snakefoot, 15 years ago)

REQUEST_URI patch for IIS

  • wp-settings.php

     
    2727
    2828// Fix for IIS, which doesn't set REQUEST_URI
    2929if ( empty( $_SERVER['REQUEST_URI'] ) ) {
    30         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
    3130
    32         // Append the query string if it exists and isn't null
    33         if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
    34                 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
     31        // IIS Mod-Rewrite
     32        if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
     33                $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
    3534        }
     35        // IIS Isapi_Rewrite
     36        else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
     37                $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
     38        }
     39        else {
     40                // If root then simulate that no script-name was specified
     41                if (empty($_SERVER['PATH_INFO']))
     42                        $_SERVER['REQUEST_URI'] = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')) . '/';
     43                else
     44                        $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
     45                       
     46                // Append the query string if it exists and isn't null
     47                if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
     48                        $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
     49                }
     50        }
    3651}
    3752
    3853// Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests