.htaccess - 在特定浏览器中禁用mod_pagespeed

时间:2017-09-20 18:02:13

标签: apache .htaccess mod-rewrite mod-pagespeed

我想针对特定浏览器使用mod_pagespeed停用.htaccess。我认为这是一个简单的问题,即创建一个RewriteCond和一个后续的RewriteRule,指定跳过 Chrome ,然后是另一组条件,这些条件会关闭mod列出的浏览器我没有收到任何错误,但规则似乎无法正常运行 - Firefox broswer仍然显示mod_pagespeed的优化。这是我尝试过的.htaccess

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} Chrome
RewriteRule .* - [L]
RewriteCond %{HTTP_USER_AGENT} ^(Mozilla.*|Safari.*|Other.*)$ [NC]
RewriteRule Mod_Pagespeed off

你可以看到它很直接。我不允许在RewriteCond / RewriteRule内关闭模块吗?

值得一提的是,每次我测试"我都清除了pagespeed缓存。这个 - 所以我没有看到缓存版本。

我也试过以下无济于事:

<If "%{HTTP_USER_AGENT} == 'Chrome'">
    # configuration for Chrome
</If>
<Else>
    <IfModule pagespeed_module>
        ModPagespeed off
    </IfModule>
</Else>

Pagespeed版本1.12.34.2-0

Mod_Pagespeed Version

<IfModule pagespeed_module>
    ModPagespeed on
    ModPagespeedInheritVHostConfig on
    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
    ModPagespeedFileCachePath            "/var/cache/mod_pagespeed/"
    ModPagespeedLogDir "/var/log/pagespeed"
    ModPagespeedSslCertDirectory "/etc/ssl/certs"
    ModPagespeedFileCacheInodeLimit        500000
    ModPagespeedImageMaxRewritesAtOnce      20

    # ModPagespeedNumRewriteThreads 4
    # ModPagespeedNumExpensiveRewriteThreads 4

    ModPagespeedPrivateNotVaryForIE on

    # Lossy image recompression quality (0 to 100, -1 just strips metadata):
    ModPagespeedImageRecompressionQuality 85

    # Jpeg recompression quality (0 to 100, -1 uses ImageRecompressionQuality):
    ModPagespeedJpegRecompressionQuality -1
    ModPagespeedJpegRecompressionQualityForSmallScreens 70
    #
    # WebP recompression quality (0 to 100, -1 uses ImageRecompressionQuality):
    ModPagespeedWebpRecompressionQuality 80
    ModPagespeedWebpRecompressionQualityForSmallScreens 70
    ModPagespeedWebpTimeoutMs 5000

    ModPagespeedMaxSegmentLength 1024

    # ModPagespeedCombineAcrossPaths off

    <Location /pagespeed_admin>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler pagespeed_admin
    </Location>
    <Location /pagespeed_global_admin>
        Order allow,deny
        Allow from localhost
        Allow from 127.0.0.1
        SetHandler pagespeed_global_admin
    </Location>

    ModPagespeedStatisticsLogging on

    ModPagespeedMessageBufferSize 100000
</IfModule>

0 个答案:

没有答案