diff --git a/filefield_paths.module b/filefield_paths.module
index c342411..e09cee2 100644
--- a/filefield_paths.module
+++ b/filefield_paths.module
@@ -289,8 +289,9 @@ function _filefield_paths_replace_path($old, $new, $entity) {
   // Build replacement.
   $info = parse_url(file_stream_wrapper_uri_normalize($new));
   $info['path'] = !empty($info['path']) ? $info['path'] : '';
-  $replacement = "_filefield_paths_replace_path_uri_scheme('\\1', '{$old}', '{$new}') . '\\2{$info['host']}{$info['path']}'";
-
+  if(!empty($info['host'])) {
+    $replacement = "_filefield_paths_replace_path_uri_scheme('\\1', '{$old}', '{$new}') . '\\2{$info['host']}{$info['path']}'";
+  }
   $fields = field_info_fields();
   foreach ($fields as $name => $field) {
     if ($field['module'] == 'text' && isset($entity->{$field['field_name']}) && is_array($entity->{$field['field_name']})) {
