0

我试过四处寻找答案,但找不到任何我能理解的教程或文档,所以我什至不确定是否可能,但是;

如果上次修改日期或 etag 在请求标头中,我想重定向/重写 URL。就像是:

RewriteEngine On 
RewriteBase /

RewriteCond # Only if the request uri is 'images/1px.gif'
RewriteCond # And if an etag or last modified date is in the req. header
RewriteRule ^(.*)$  /304-this.php [L]

请注意,即使这是可能的,如果这不是您建议的更好选择。

为了清楚起见,我也只希望在请求是针对images/1px.gif并且有 etag 或最后修改日期时触发此重定向。

我的理论是,如果图像已经在浏览器缓存中,它将与 etag 或最后修改日期一起发送,在这种情况下,我希望 PHP 处理 304 响应。

谢谢大家!

4

1 回答 1

1

您可以%{HTTP:...}在 aRewriteCond中用于测试任何标头

RewriteCond %{HTTP:etag} . [OR]
RewriteCond %{HTTP:last-modified} .
RewriteRule images/1px.gif$ /304-this.php [L]
于 2013-02-22T17:18:14.713 回答