Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.95
diff -u -r1.95 file.inc
--- includes/file.inc	27 Mar 2007 05:13:53 -0000	1.95
+++ includes/file.inc	11 Apr 2007 11:23:03 -0000
@@ -27,15 +27,27 @@
  * @return A string containing a URL that can be used to download the file.
  */
 function file_create_url($path) {
-  // Strip file_directory_path from $path. We only include relative paths in urls.
-  if (strpos($path, file_directory_path() . '/') === 0) {
-    $path = trim(substr($path, strlen(file_directory_path())), '\\/');
-  }
   switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
     case FILE_DOWNLOADS_PUBLIC:
-      return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path);
+      // When file_directory_path is absolute and in Drupal's root directory,
+      // strip the root directory from $path.
+      if (strpos($path, file_directory_path() .'/') === 0) {
+        $drupal_root = dirname($_SERVER['SCRIPT_FILENAME']);
+        if (strpos(file_directory_path() .'/', $drupal_root .'/') === 0) {
+          $path = substr($path, strlen($drupal_root .'/'));
+        }
+      }
+      else {
+        $path = file_directory_path() .'/'. $path;
+      }
+      return $GLOBALS['base_url'] .'/'. str_replace('\\', '/', $path);
+
     case FILE_DOWNLOADS_PRIVATE:
-      return url('system/files/'. $path, array('absolute' => TRUE));
+      // Strip file_directory_path from $path. We only include relative paths in urls.
+      if (strpos($path, file_directory_path() .'/') === 0) {
+        $path = trim(substr($path, strlen(file_directory_path())), '\\/');
+      }
+      return url('system/files/'. $path, NULL, NULL, TRUE);
   }
 }
 
