我正在使用htaccess重写:
# ENABLE REWRITE
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^gallery/(.+)$ /image.php?image=$1 [L,QSA,NC]
# EXPIRES CACHING
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
如您所见,我也使用.htaccess设置过期时间。如果我删除行RewriteRule ^gallery/(.+)$ /image.php?image=$1 [L,QSA,NC]
,则过期有效,但显然我会遇到重写问题。我怎样才能将这两件事结合在一起呢?
我在LiteSpeed服务器上。
答案 0 :(得分:1)
您可以针对重写的PHP文件尝试此FilesMatch
指令:
<FilesMatch "image\.php$">
ExpiresDefault "access plus 1 year"
</FilesMatch>