diff --git a/sites/all/modules/unl/includes/unl.admin.inc b/sites/all/modules/unl/includes/unl.admin.inc
index 7fd339b35c81f612f69d545193400d75101dceaa..59f83c744bd0fe8d833cec0f932ed73fd91750f6 100644
--- a/sites/all/modules/unl/includes/unl.admin.inc
+++ b/sites/all/modules/unl/includes/unl.admin.inc
@@ -14,6 +14,13 @@ function unl_config($form, &$form_state) {
     '#description' => 'Insert the HTML Base tag in the head of all pages on this site.',
     '#default_value' => variable_get('unl_use_base_tag', TRUE),
   );
+  
+  $form['root']['unl_clean_file_url'] = array(
+    '#type' => 'checkbox',
+    '#title' => 'Clean File URLs',
+    '#description' => 'Enable this once mod_rewrite has been set up to support clean file URLs',
+    '#default_value' => variable_get('unl_clean_file_url'),
+  );
 
   $form['submit'] = array(
     '#type' => 'submit',
@@ -25,4 +32,5 @@ function unl_config($form, &$form_state) {
 
 function unl_config_submit($form, &$form_state) {
   variable_set('unl_use_base_tag', $form_state['values']['root']['unl_use_base_tag']);
+  variable_set('unl_clean_file_url', $form_state['values']['root']['unl_clean_file_url']);
 }
diff --git a/sites/all/modules/unl/unl.js b/sites/all/modules/unl/unl.js
new file mode 100644
index 0000000000000000000000000000000000000000..acdb0a0960821ef67da4048348ee857968df207a
--- /dev/null
+++ b/sites/all/modules/unl/unl.js
@@ -0,0 +1,25 @@
+/**
+ * On IMCE pages, modify IMCE to return relative paths when a base tag is being used.
+ */
+jQuery('document').ready(function() {
+	// If this isn't an IMCE page, we don't need to do anything.
+	if (typeof(imce) == 'undefined') {
+		return;
+	}
+	// If we aren't using a base tag, we don't need to do anything.
+	if (!Drupal.settings.unl.use_base_tag) {
+		return;
+	}
+	// Change imce's base url to the current directory.
+	Drupal.settings.imce.furl = ".";
+	// Override imce's getURL method to remove a trailing ./ from URLs.
+	imce.realGetURL = imce.getURL;
+	imce.getURL = function(fid) {
+		var url = imce.realGetURL(fid);
+		if (url.substr(0, 2) == './') {
+			url = url.substr(2);
+		}
+		return url;
+	};
+});
+
diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module
index ef83028162ac168f4fd7418ba0144f71aaaf32f6..e31c4cedd6afef6ed28f7d4b484704349a62b226 100644
--- a/sites/all/modules/unl/unl.module
+++ b/sites/all/modules/unl/unl.module
@@ -983,6 +983,7 @@ function unl_init() {
     );
     drupal_add_html_head($base_tag, 'base');
   }
+  drupal_add_js(array('unl' => array('use_base_tag' => variable_get('unl_use_base_tag', TRUE))), 'setting');
   
   _unl_handle_directory_index();
 }
@@ -1272,7 +1273,27 @@ function unl_block_view_my_sites()
   return $block;
 }
 
+/**
+ * Implements hook_stream_wrappers_alter().
+ */
+function unl_stream_wrappers_alter(&$wrappers) {
+  if (variable_get('unl_clean_file_url')) {
+    $wrappers['public']['class'] = 'UnlPublicStreamWrapper';
+  }
+}
 
-
+class UnlPublicStreamWrapper extends DrupalPublicStreamWrapper {
+  function getExternalUrl() {
+    $url = $GLOBALS['base_url'];
+    
+    if (!variable_get('unl_clean_file_url')) {
+      $url .= '/' . self::getDirectoryPath();
+    }
+    
+    $path = str_replace('\\', '/', $this->getTarget());
+    $url .= '/' . drupal_encode_path($path);
+    return $url;
+  }
+}
 
 
diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php
index 92622aae6b6c442a9a91d98f8ac200c69112f763..7fd9ce6a8ccc809f58db8f19752e5da331e13122 100644
--- a/sites/all/modules/unl/unl_migration.php
+++ b/sites/all/modules/unl/unl_migration.php
@@ -595,7 +595,7 @@ class Unl_Migration_Tool
             } catch (Exception $e) {
               $this->_log('Could not migrate file "' . $path . '"! File name too long?', WATCHDOG_ERROR);
             }
-            $this->_hrefTransformFiles[$path] = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath() . '/' . $path;
+            $this->_hrefTransformFiles[$path] = $this->_makeRelativeUrl(file_create_url('public://' . $path));
             return;
         }
         $html = $data['content'];
@@ -818,6 +818,30 @@ class Unl_Migration_Tool
         return $absoluteUrl;
     }
     
+    /**
+     * Given an absolute URL $href, returns a URL that is relative to $baseUrl
+     * @param string $href
+     * @param string[optional] $baseUrl
+     */
+    private function _makeRelativeUrl($href, $baseUrl = '') {
+      if (!$baseUrl) {
+        $baseUrl = url('<front>', array('absolute' => TRUE));
+      }
+      
+      if (substr($href, 0, strlen($baseUrl)) == $baseUrl) {
+        if (variable_get('unl_use_base_tag', TRUE)) {
+          return substr($href, strlen($baseUrl));
+        } else {
+          $parts = parse_url($href);
+          $relativeUrl = $parts['path'];
+          $relativeUrl .= isset($parts['query']) ? '?' . $parts['query'] : '';
+          $relativeUrl .= isset($parts['fragment']) ? '#'.$parts['fragment'] : '';
+          return $relativeUrl;
+        }
+      }
+      return $href;
+    }
+    
     private function _createPage($title, $content, $alias = '', $makeFrontPage = FALSE)
     {