[英]Apache .htaccess for deny all files in a folder not ending with .min.js?
I'm already using (in my /web/css
folder) the following .htaccess
file for obscuring source .less
files (LESS files): 我已经使用(在我的/web/css
文件夹中)以下.htaccess
文件遮盖了源.less
文件(LESS文件):
<Files ~ "\.less$">
Order allow,deny
Deny from all
</Files>
I can't do something very similar for JavaScript files in /web/js
: deny if the file doesn't end in .min.js
. 对于/web/js
JavaScript文件,我无法执行类似的操作:如果文件未以.min.js
结尾,请.min.js
。 This maybe due to my little understanding of regular expression, so please go easy with me! 这可能是由于我对正则表达式的了解不多,所以请和我一起努力吧!
<Files ~ "[^min]\.js$">
Order allow,deny
Deny from all
</Files>
A file not ending with min.js
should be denied, but - actually - seems to allow all. 不以min.js
结尾的文件应该被拒绝,但是-实际上-似乎允许所有。
Try FilesMatch
like this: 像这样尝试FilesMatch
:
<FilesMatch "(?!^.*min\.js$)^.+?\.js$">
Order allow,deny
Deny from all
</FilesMatch>
Alternative solution using mod_rewrite: 使用mod_rewrite的替代解决方案:
RewriteEngine On
RewriteRule !^min\.js$ - [F]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.