当前位置 主页 > 服务器问题 > Linux/apache问题 >

    apache .htaccess文件详解和配置技巧总结(4)

    栏目:Linux/apache问题 时间:2018-09-29 13:35

    代码如下:ErrorDocument 401 /error/401.php 
    ErrorDocument 403 /error/403.php 
    ErrorDocument 404 /error/404.php 
    ErrorDocument 500 /error/500.php
    6. 压缩文件
    通过压缩你的文件体积来优化网站的访问速度。
    复制代码 代码如下:# 压缩 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 
    7. 缓存文件
    缓存文件是另外一个提高你的网站访问速度的好方法。
    复制代码 代码如下:<FilesMatch “.(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$”> 
    Header set Cache-Control “max-age=2592000″ 
    </FilesMatch> 
    8. 对某些文件类型禁止使用缓存
    而另一方面,你也可以定制对某些文件类型禁止使用缓存。
    复制代码 代码如下:# 显式的规定对脚本和其它动态文件禁止使用缓存 
    <FilesMatch “.(pl|php|cgi|spl|scgi|fcgi)$”> 
    Header unset Cache-Control 
    </FilesMatch>