--- securepages.module	2011-03-17 13:43:14.944483471 -0400
+++ securepages.module.patched12	2011-03-17 13:42:43.120485421 -0400
@@ -26,6 +26,12 @@ function securepages_boot() {
   }
 
   /**
+   * Correct the $base_root global when $base_url is set in settings.php
+   */
+  global $base_root;
+  $base_root = securepages_baseurl(securepages_is_secure(), $base_root); 
+
+  /**
    * If this is a cached page we need to do the check here even though we
    * have no access to the menu.
    */
@@ -377,9 +383,20 @@ function securepages_url($path = NULL, $
 
 /**
  * Return the secure base path
- */
-function securepages_baseurl($secure = TRUE) {
-  global $base_url;
+ * 
+ * @param $secure
+ *   Boolean to indicate this page is secure (TRUE) or not
+ * @param $base
+ *   An optional alternative base URL to parse (defaults to $base_url)
+ */
+function securepages_baseurl($secure = TRUE, $base = NULL) {
+  if (!$base) {
+    global $base_url;
+    $base_path = $base_url;
+  }
+  else {
+    $base_path = $base;
+  }
 
   if ($secure) {
     $url = variable_get('securepages_basepath_ssl', NULL);
@@ -393,7 +410,7 @@ function securepages_baseurl($secure = T
   }
 
   // No url has been set, so convert the base_url from 1 to the other
-  return preg_replace('/http[s]?:\/\//i', ($secure ? 'https://' : 'http://'), $base_url, 1);
+  return preg_replace('/http[s]?:\/\//i', ($secure ? 'https://' : 'http://'), $base_path, 1);
 }
 
 /**
@@ -465,3 +482,4 @@ function securepages_exit() {
     unset($_SESSION['securepages_redirect']);
   }
 }
+
