title: Block direct access to js, css file but allow access from index.html?
body: <p>This is my directory look like:</p>
  
  <ul>
  <li>index.html</li>
  <li>data.js</li>
  <li>.htaccess</li>
  </ul>
  
  <p>Content in index.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;script src="data.js" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My problem is: </p>
  
  <ul>
  <li><p>I don't want user to see my <code>data.js</code> by direct link like <code>www.sample.com/data.js</code> </p></li>
  <li><p>But <code>data.js</code> still allow access from <code>index.html</code></p></li>
  </ul>
  
  <p>I tried in .htaccess like:</p>
  
  <pre><code>deny from all
  </code></pre>
  
  <p>or</p>
  
  <pre><code>RewriteEngine on 
  RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] 
  RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] 
  RewriteRule \.(gif|jpg|css|js|png)$ - [F]
  </code></pre>
  
  <p>But it alway block access from index.html too.</p>
  
  <p>Thanks.</p>