deflate/gzip 可以与“deny from all”一起使用吗?
我对 .htaccess 文件有点困惑。我想要 gzip 压缩并拒绝目录中的所有内容。我的问题是“拒绝所有”可以与 gzip 压缩一起使用还是有任何问题?
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
deny from all
I am kind of confused with the .htaccess file. I want gzip compression and deny from all in a directory. My question is can "deny from all" be with gzip compression or it has any problems?
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
deny from all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
deny from all
表示任何人都无法通过 URL 直接访问该目录。从该目录发送到浏览器的任何内容都必须通过放置在其他地方的服务器端脚本来实现,这意味着 .htaccess 被完全绕过 - 因此不会进行压缩。因此,您的服务器端脚本必须先使用
http_deflate
自行执行压缩输出这些文件中的数据。deny from all
means no one can access the directory directly via a URL. Any content sent to the browser from that directory has to come via a server-side script placed elsewhere, which means that .htaccess is bypassed entirely - so the compression won't take place.Your server-side script will therefore have to perform the compression on its own using
http_deflate
before outputting the data from those files.