[英]Disable display of .css and .js files content in the browser
Before this question I asked about disabling file and folder listing and I found an answer that this can be done with a file called .htaccess. 在问这个问题之前,我问过关于禁用文件和文件夹列表的问题,我发现一个答案可以通过名为.htaccess的文件来完成。 For disabling folder listing I write Options -Indexes in the .htaccess file and place it in the parent folder, on the other hand for disabling display of files content in the browser I write Deny from all. 为了禁用文件夹列表,我在.htaccess文件中写入Options -Indexes并将其放置在父文件夹中,另一方面,要在浏览器中禁用文件内容的显示,我则全部拒绝。
The above part functions good, but when a putted the .htaccess file for disabling display of files content in the css or js folder, it disables display of files and also blocks the functionality of them (.css and .js). 上面的部分功能很好,但是当放置.htaccess文件以禁用css或js文件夹中文件内容的显示时,它将禁用文件的显示并阻止它们的功能(.css和.js)。
Is there an answer that disables the display of files in the browser but allows the functionality of them? 是否有一个答案可以禁用浏览器中文件的显示,但允许其功能?
Thank you 谢谢
No. 没有。
You can turn off directory listings because nothing needs to see them. 您可以关闭目录列表,因为不需要查看它们。
You can't turn off display of CSS or JS because the browser has to be able to see them in order to use them for what they are designed for. 您无法关闭CSS或JS的显示,因为浏览器必须能够看到它们才能将其用于设计目的。 Anything the browser can see, the user can see too. 浏览器可以看到的任何内容,用户也可以看到的。
可以禁用文件列表,但是您不能保护它们,因为它们是网站加载样式或功能所必需的...
Try looking up minifying and obfuscating. 尝试查找缩小和混淆。
Minifying makes your files harder to read. 缩小会使文件更难阅读。 Obfuscating can completely encode your files (only tried with JS so far myself). 混淆可以完全编码您的文件(到目前为止,只有我自己使用JS尝试过)。 But be sure to keep a backup of your files, because once encrypted, you can't go back. 但是请务必保留文件的备份,因为一旦加密,就无法返回。
Here is a link for obfuscating JS files: 这是混淆JS文件的链接:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.