diff --git a/xmlsitemap.module b/xmlsitemap.module
old mode 100644
new mode 100755
index 93e935f..83040d8
--- a/xmlsitemap.module
+++ b/xmlsitemap.module
@@ -771,6 +771,14 @@ function _xmlsitemap_check_changed_link(array $link, $original_link = NULL, $fla
 }
 
 /**
+ * Fix to building xml sitemap file uri.
+ */
+function xmlsitemap_file_build_uri($path) {
+  $uri = 'public://' . $path;
+  return file_stream_wrapper_uri_normalize($uri);
+}
+
+/**
  * @} End of "defgroup xmlsitemap_api"
  */
 
@@ -780,12 +788,12 @@ function xmlsitemap_get_directory(stdClass $sitemap = NULL) {
   if (!isset($directory)) {
     $directory = variable_get('xmlsitemap_path', 'xmlsitemap');
   }
-
+  
   if (!empty($sitemap->smid)) {
-    return file_build_uri($directory . '/' . $sitemap->smid);
+    return xmlsitemap_file_build_uri($directory . '/' . $sitemap->smid);
   }
   else {
-    return file_build_uri($directory);
+    return xmlsitemap_file_build_uri($directory);
   }
 }
 
