public static function createHtAccessFiles()
    {
        $denyAll = self::getDenyAllHtaccessContent();
        $allow = self::getAllowHtaccessContent();

        $allowAny =
            "# Allow any file in this directory\n" .
            "<Files \"*\">\n" .
            "\t" . $allow . "\n" .
            "</Files>\n";

        $allowStaticAssets =
            "# Serve HTML files as text/html mime type - Note: requires mod_mime apache module!\n" .
            "<IfModule mod_mime.c>\n" .
            "   AddHandler text/html .html\n" .
            "   AddHandler text/html .htm\n" .
            "</IfModule>\n\n" .

            "# Allow to serve static files which are safe\n" .
            "<Files ~ \"\\.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$\">\n" .
            $allow . "\n" .
            "</Files>\n";

        $noCachePreview = "
# do not cache preview container files
<Files  ~ \"^container_.*_preview\.js$\">
<IfModule mod_headers.c>
Header set Cache-Control \"Cache-Control: private, no-cache, no-store\"
</IfModule>
</Files>";

        $directoriesToProtect = array(
            '/js'        => $allowAny . $noCachePreview,
            '/libs'      => $denyAll . $allowStaticAssets,
            '/vendor'    => $denyAll . $allowStaticAssets,
            '/plugins'   => $denyAll . $allowStaticAssets,
            '/misc/user' => $denyAll . $allowStaticAssets,
        );
        foreach ($directoriesToProtect as $directoryToProtect => $content) {
            self::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
        }

        // deny access to these folders
        $directoriesToProtect = array(
            '/config' => $denyAll,
            '/core' => $denyAll,
            '/lang' => $denyAll,
            '/tmp' => $denyAll,
        );
        foreach ($directoriesToProtect as $directoryToProtect => $content) {
            self::createHtAccess(PIWIK_INCLUDE_PATH . $directoryToProtect, $overwrite = true, $content);
        }
    }