deflate/gzip 可以与“deny from all”一起使用吗?

发布于 2024-12-08 18:39:11 字数 694 浏览 0 评论 0原文

我对 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

舂唻埖巳落 2024-12-15 18:39:11

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文