Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.367
diff -u -r1.367 bootstrap.inc
--- includes/bootstrap.inc	26 Mar 2010 17:14:45 -0000	1.367
+++ includes/bootstrap.inc	31 Mar 2010 18:06:12 -0000
@@ -471,6 +471,12 @@
  * Initialize PHP environment.
  */
 function drupal_environment_initialize() {
+  // Export the following settings.php variables to the global namespace
+  global $base_url, $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
+  if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
+    include_once DRUPAL_ROOT . '/' . conf_path() . '/settings.php';
+  }
+
   if (!isset($_SERVER['HTTP_REFERER'])) {
     $_SERVER['HTTP_REFERER'] = '';
   }
@@ -543,16 +549,10 @@
  * session name correctly.
  */
 function drupal_settings_initialize() {
+  global $cookie_domain, $conf, $is_https, $base_secure_url, $base_insecure_url;
   global $base_url, $base_path, $base_root;
-
-  // Export the following settings.php variables to the global namespace
-  global $databases, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url;
   $conf = array();
 
-  if (file_exists(DRUPAL_ROOT . '/' . conf_path() . '/settings.php')) {
-    include_once DRUPAL_ROOT . '/' . conf_path() . '/settings.php';
-  }
-
   if (isset($base_url)) {
     // Parse fixed base URL from settings.php.
     $parts = parse_url($base_url);
@@ -2168,6 +2168,7 @@
  * @see current_path()
  */
 function request_path() {
+  global $base_url;
   static $path;
 
   if (isset($path)) {
@@ -2184,7 +2185,12 @@
   elseif (isset($_SERVER['REQUEST_URI'])) {
     // This is a request using a clean URL. Extract the path from REQUEST_URI.
     $request_path = strtok($_SERVER['REQUEST_URI'], '?');
-    $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
+    if ($base_url) {
+      $base_path_len = strlen($base_url)- 7 - strlen($_SERVER['HTTP_HOST']);
+    }
+    else {   
+      $base_path_len = strlen(rtrim(dirname($_SERVER['SCRIPT_NAME']), '\/'));
+    }    
     // Unescape and strip $base_path prefix, leaving q without a leading slash.
     $path = substr(urldecode($request_path), $base_path_len + 1);
   }
