我正在尝试使用以下代码,但似乎永远不会设置环境变量SETEXPIRE
。如果我删除它有效的IfDefine SETEXPIRE
部分,但我需要那部分。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|&)_=(.*)
RewriteRule .* - [E=SETEXPIRE:yes]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^html/(.*?)$ index.php?url=$1&%{QUERY_STRING} [L,NC]
<IfDefine SETEXPIRE>
<filesMatch "(?!\.(png|jpe?g|css|js|gif))$">
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 3 months"
<IfModule mod_headers.c>
Header set Cache-Control "max-age=2592000, public, no-transform"
Header set pragma ""
</IfModule>
</IfModule>
</filesMatch>
</IfDefine>
任何帮助都将不胜感激。
我想尝试做的是设置expire头,如果请求的文件扩展名是png | jpe?g | css | js | gif和查询字符串中设置了key _
答案 0 :(得分:0)
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|&)_=(.*)
RewriteCond %{QUERY_STRING} !(^|&)_=0(&|$)
RewriteRule .* - [E=SETEXPIRE:yes]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^html/(.*?)$ index.php?url=$1&%{QUERY_STRING} [L,NC]
<filesMatch "(?!\.(png|jpe?g|css|js|gif))$">
Header set Cache-Control "max-age=2592000, public, no-transform" env=SETEXPIRE
Header set pragma "" env=SETEXPIRE
</filesMatch>
欢呼声 c_bb