首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利用浏览器缓存-修改.htaccess文件时出现内部服务器错误

问利用浏览器缓存-修改.htaccess文件时出现内部服务器错误
EN

Stack Overflow用户
提问于 2013-10-02 01:08:37
回答 1查看 1K关注 0票数 0

我在试着加速我的网站。在谷歌PageSpeed Insights上,我有86分,但我对Leverage browser caching有问题。在推荐中,我发现了这段.htaccess代码:

代码语言:javascript
复制
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

但是当我将它插入到我的.htaccess文件时,我得到了内部服务器错误(500)。

我的工作.htaccess代码就像这样:

代码语言:javascript
复制
AddHandler x-httpd-php53 .php 

RewriteEngine On
RewriteBase /
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

# Insert filter
SetOutputFilter DEFLATE

# 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
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

我哪里做错了?

EN

回答 1

Stack Overflow用户

发布于 2016-06-22 21:15:50

我认为你应该在服务器上启用模块"mod_expires“:使用ubuntu服务器类型:

a2enmod过期

/etc/init.d/apache2重启

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19122044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档