6

私はgzipdeflateの問題を解決しようとして約48時間ですが、助けを求める必要があるかもしれないことに気づきました。

php.iniファイルで圧縮をオンにする必要があることに気付いた後、ついに.htaccessを介して共有Unixサーバーでdeflateモジュールを有効にしました。

PageSpeedによると、ルートHTMLはサイトのgzipでエンコードされており、Wordpressサイトtheoleandersofsanleon.comでは77.3%の圧縮率が得られていますが、サブディレクトリ内のファイルはどれも圧縮されていません(主にWordpressのcssファイルとjsファイル)ディレクトリとそのサブディレクトリ)。

私はそれが必要だとは思いませんでしたが、先に進んで、ディレクティブDirectoryを使用してから、ディレクティブLocationを使用しようとしましたが無駄になりました。

サーバーの仕様でphpinfo.phpファイルを確認する必要がある場合は、ルートにphpinfo.phpファイルを配置します。

htdocsディレクトリとwordpressディレクトリの両方の.htaccessファイルにあるものは次のとおりです。

<IfModule mod_deflate.c>
# Insert filters
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
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

さらに情報が必要な場合はお知らせください。ご協力いただきありがとうございます。よろしくお願いいたします。髪の毛を元に戻すことができます8-)

4

1 に答える 1

0

トップレベルの .htaccess ファイルでこれを試してください。これは、cPanel でオプティマイザーを使用したときに生成されるコンテンツです。

<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
  <IfModule mod_setenvif.c>
    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
    # the above regex won't work. You can use the following
    # workaround to get the desired effect:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

    # Don't compress images
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
  </IfModule>

  <IfModule mod_headers.c>
    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
  </IfModule>
</IfModule>
于 2013-01-03T12:17:37.690 に答える