--- includes/common.inc
+++ includes/common.inc
@@ -3392,8 +3392,8 @@
         // Move to the parent.
         $css_base_url = substr($css_base_url, 0, strrpos($css_base_url, '/'));
         // Simplify to a relative URL if the stylesheet URL starts with the
-        // base URL of the website.
-        if (substr($css_base_url, 0, strlen($GLOBALS['base_root'])) == $GLOBALS['base_root']) {
+        // base URL of the website and has no other domain/port parts
+        if ((substr($css_base_url, 0, strlen($GLOBALS['base_root'])) == $GLOBALS['base_root']) && (substr($css_base_url, strlen($GLOBALS['base_root']), 1) == '/')) {
           $css_base_url = substr($css_base_url, strlen($GLOBALS['base_root']));
         }
 
