如何美元,CSS和JS文件p $ pvent直接访问 [英] How to prevent direct access to CSS and JS files

查看:105
本文介绍了如何美元,CSS和JS文件p $ pvent直接访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/6335644/how-can-i-block-direct-access-to-my-javascript-files\">How我可以阻止我的JavaScript文件直接访问?

我有一个文件夹,里面有大约五个看起来像如下:

I have a folder and inside it there are around five more which looks like following:

 1.asset(folder)
       1.1 css (subfolder)
              1.1.1 style.css (file)
       1.2 javascript (subfolder)
                     1.2.1 validation.js (file)
 // goes on like this

现在我的问题是如何prevent我的CSS出现时,任何用户点击 - ?在浏览my_base_url /资产/ CSS / style.css中

Now my question is how to prevent my css to appear when any user hits - my_base_url/asset/css/style.css on the browse?

我试过空白的index.html,但它不工作。我使用.htaccess文件,但在这种情况下,当我加载我的网站上没有找到CSS的所有拒绝也试过..

I tried blank index.html but it doesn't work. I also tried using "deny from all" .htaccess file but in this case when I load my website it doesn't find the CSS..

推荐答案

什么你问的是,从技术上讲,是不可能的。

What you're asking for is, technically, impossible.

为了为浏览器能够使用的CSS,它必须能够访问它。同上的JavaScript。

In order for the browser to be able to use the CSS, it must have access to it. Ditto Javascript.

你能做的最好的是的模糊处理的来源。如触控笔或LessCSS为CSS和CoffeeScript的对JS - - 或者通过使递送更复杂的可以通过使用一个处理语言做到这一点。你可以再缩小脚本文件,甚至可以让他们动态另一个JS文件产生的进账(小片)。

The best you can do is obfuscate the sources. You could do this by using a processed language - such as Stylus or LessCSS for CSS, and Coffeescript for JS - or by making the delivery more complicated. You could minify the script files, or even have them dynamically generated and fetched (in small pieces) by another JS file.

不过,任何事情你尽可以进行逆向工程,因为用户的必须能够访问规则,以便为浏览器使用它们

However, anything you do can be reverse-engineered, because the users must be able to access the rules in order for the browser to use them.

这篇关于如何美元,CSS和JS文件p $ pvent直接访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆