如何在Apache中禁用响应头中的User-Agent

时间:2016-06-16 05:42:21

标签: apache .htaccess http-headers

我尝试了一些.htaccess命令,例如RequestHeader unset User-Agent

但它不起作用。我还删除了压缩,以检查它是否是triger用户代理,但它不是。

你能告诉我如何从我的响应标题中删除Vary User-Agent。我认为它默认存在。

可能必须从cPanel&南国。如果是这种情况,那么你可以指导我如何做到这一点吗?

或者如果要通过.htaccess完成,那么我也需要你的帮助来解决这个问题。

以下是我的.htaccess目前的样子:

# ------------------------------------------------------------------------------
# |     Web fonts access                                                           |
# ------------------------------------------------------------------------------

# Allow access from all domains for web fonts

<IfModule mod_headers.c>
   <FilesMatch "\.(eot|otf|ttc|ttf|woff)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>

# ------------------------------------------------------------------------------
# | Compression                                                                |
# ------------------------------------------------------------------------------


<IfModule mod_deflate.c>
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE text/javascript
 AddOutputFilterByType DEFLATE text/xml
 AddOutputFilterByType DEFLATE text/plain
 AddOutputFilterByType DEFLATE image/x-icon
 AddOutputFilterByType DEFLATE image/svg+xml
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE application/x-javascript
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/x-font
 AddOutputFilterByType DEFLATE application/x-font-truetype
 AddOutputFilterByType DEFLATE application/x-font-ttf
 AddOutputFilterByType DEFLATE application/x-font-otf
 AddOutputFilterByType DEFLATE application/x-font-eot
 AddOutputFilterByType DEFLATE application/x-font-woff
 AddOutputFilterByType DEFLATE application/x-font-opentype
 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
 AddOutputFilterByType DEFLATE font/ttf
 AddOutputFilterByType DEFLATE font/woff
 AddOutputFilterByType DEFLATE font/eot
 AddOutputFilterByType DEFLATE font/svg
 AddOutputFilterByType DEFLATE font/otf
 AddOutputFilterByType DEFLATE font/opentype


# For Olders Browsers Which Can't Handle Compression
 BrowserMatch ^Mozilla/4 gzip-only-text/html
 BrowserMatch ^Mozilla/4\.0[678] no-gzip
 BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

# ------------------------------------------------------------------------------
# | Add Expiry and Unset Pragma and ETag                                       |
# ------------------------------------------------------------------------------
Header unset Pragma

# 1 Month for most static assets 3 months for proxies
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|swf)(\.gz)?$">
Header set Cache-Control "max-age=2592000, s-maxage=7776000, must-revalidate, proxy-revalidate, no-transform"
Header unset ETag
FileETag None
</FilesMatch>


# 3 Days for normal and 1 week for proxies
<filesMatch ".(css|xml|html|php)$">
Header set Cache-Control "max-age=259200, s-maxage=604800, must-revalidate,   proxy-revalidate, no-transform"
Header unset ETag
FileETag None
</FilesMatch>


#-------------------------------------------------------------------------------

非常感谢任何帮助。提前谢谢!

0 个答案:

没有答案