diff --git a/.htaccess b/.htaccess
index 60cfcc41c9fe8..40d40ac8feed3 100644
--- a/.htaccess
+++ b/.htaccess
@@ -4,12 +4,6 @@
# SetEnv MAGE_MODE developer
-############################################
-## overrides default umask value to allow using different
-## file permissions
-
-# SetEnv MAGE_UMASK 022
-
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
@@ -285,6 +279,10 @@
order allow,deny
deny from all
+
+ order allow,deny
+ deny from all
+
################################
## If running in cluster environment, uncomment this
diff --git a/.htaccess.sample b/.htaccess.sample
index 186c51ddf4211..fb787293d6185 100644
--- a/.htaccess.sample
+++ b/.htaccess.sample
@@ -3,12 +3,6 @@
# SetEnv MAGE_MODE developer
-############################################
-## overrides default umask value to allow using different
-## file permissions
-
-# SetEnv MAGE_UMASK 022
-
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
@@ -251,6 +245,10 @@
order allow,deny
deny from all
+
+ order allow,deny
+ deny from all
+
################################
## If running in cluster environment, uncomment this
diff --git a/app/bootstrap.php b/app/bootstrap.php
index ae15b1ad4c0c2..0b47e6303cf3f 100644
--- a/app/bootstrap.php
+++ b/app/bootstrap.php
@@ -10,10 +10,6 @@
error_reporting(E_ALL);
#ini_set('display_errors', 1);
-/* Custom umask value may be provided in MAGE_UMASK environment variable */
-$mask = isset($_SERVER['MAGE_UMASK']) ? octdec($_SERVER['MAGE_UMASK']) : 002;
-umask($mask);
-
/* PHP version validation */
if (version_compare(phpversion(), '5.5.0', '<') === true) {
if (PHP_SAPI == 'cli') {
@@ -34,6 +30,11 @@
require_once __DIR__ . '/autoload.php';
require_once BP . '/app/functions.php';
+/* Custom umask value may be provided in optional mage_umask file in root */
+$umaskFile = BP . '/magento_umask';
+$mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;
+umask($mask);
+
if (!empty($_SERVER['MAGE_PROFILER'])
&& isset($_SERVER['HTTP_ACCEPT'])
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
diff --git a/pub/.htaccess b/pub/.htaccess
index 73b76bb10b4b4..5269df415f803 100644
--- a/pub/.htaccess
+++ b/pub/.htaccess
@@ -3,12 +3,6 @@
# SetEnv MAGE_MODE developer
-############################################
-## overrides default umask value to allow using different
-## file permissions
-
-# SetEnv MAGE_UMASK 022
-
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name