Tüm web sayfamı sıkıştırmak için bu .htaccess kodunu kullanıyorum. Mümkünse Apache deflate
modülünü kullanır, PHP
ob_gzhandler
sıkıştırmasını uygulayın.Mod_deflate & PHP'nin sadece bir dizinde sıkıştırmayı atlamasını söyleyebilir miyim?
Her şey yolunda çalışıyor, ancak belirli bir nedenle, ./folderWithoutCompression
klasörü için sıkıştırmayı uygulamak istemiyorum.
Soru: Nasıl tanımlanır Apache deflate
modülü durumunda bu durum ekleyebilirsiniz veya olmasın (PHP ob_gzhandler
) Lütfen benim şu komut?
<IfModule mod_deflate.c>
# force deflate for mangled headers
# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
<IfModule filter_module>
FilterDeclare COMPRESS
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
FilterChain COMPRESS
FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
</IfModule>
<IfModule !mod_filter.c>
# Legacy versions of Apache
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/atom+xml
AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font-ttf font/opentype
</IfModule>
</IfModule>
<IfModule !mod_deflate.c>
#Apache deflate module is not defined, active the page compression through PHP ob_gzhandler
php_flag output_buffering On
php_value output_handler ob_gzhandler
</IfModule>
Çözüm olarak
DÜZENLEME, benim folderWithoutCompression klasöründe bulunan tüm dosyaları için özel bir content-type
kullanıyorum.
yazabilir Ben <Location>
, <LocationMatch
>, <DirectoryMatch
> veya <Directory
> kullanarak bazı dizin dışlamak mümkün olduğunu eminim, ama ben başa çalıştığınızda, hep bir Apache hata 500
Belki mümkün değil mi? – sdespont
Sonunda burada cevap bulmak: https://stackoverflow.com/questions/1922934/how-to-disable-mod-deflate-in-apache2 Sırf senin soru upvoted sayesinde @Gumbo – sdespont
Benim için bir cevap olarak hizmet etti: Daha önce bu filtre modülünü hiç duymadım, teşekkürler! – Niavlys