snipt

Ctrl+h for KB shortcuts

Text only

Block Access to Hidden Files and Directories

# We try to push our code to productions servers without hidden files and directors,
# like our revision system directors, but that doesn’t always happen.
# This snippet prevents those files from being accessible:

<IfModule mod_rewrite.c>
    RewriteCond %{SCRIPT_FILENAME} -d [OR]
    RewriteCond %{SCRIPT_FILENAME} -f
    RewriteRule "(^|/)\." - [F]
</IfModule>

http://davidwalsh.name/html5-boilerplate-htaccess
https://snipt.net/embed/9d04210c977ba8aa3a7c0ce672c88540/
/raw/9d04210c977ba8aa3a7c0ce672c88540/
9d04210c977ba8aa3a7c0ce672c88540
text
Text only
11
2019-08-19T10:43:42
True
False
False
/api/public/snipt/100825/
block-access-to-hidden-files-and-directories
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a># We try to push our code to productions servers without hidden files and directors, </span><span id="L-2"><a name="L-2"></a># like our revision system directors, but that doesn’t always happen. </span><span id="L-3"><a name="L-3"></a># This snippet prevents those files from being accessible: </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>&lt;IfModule mod_rewrite.c&gt; </span><span id="L-6"><a name="L-6"></a> RewriteCond %{SCRIPT_FILENAME} -d [OR] </span><span id="L-7"><a name="L-7"></a> RewriteCond %{SCRIPT_FILENAME} -f </span><span id="L-8"><a name="L-8"></a> RewriteRule &quot;(^|/)\.&quot; - [F] </span><span id="L-9"><a name="L-9"></a>&lt;/IfModule&gt; </span><span id="L-10"><a name="L-10"></a> </span><span id="L-11"><a name="L-11"></a>http://davidwalsh.name/html5-boilerplate-htaccess </span></pre></div> </td></tr></table>
htaccess, vhost