我一直在编写一个脚本来使用 PHP 生成较低分辨率的图像副本。我正在努力使用 mod_write 仅当文件不存在时才执行 PHP 脚本
我目前拥有的(可能会有所偏差,因为我今天已经进行了数千次尝试)如下:
RewriteCond %{REQUEST_URI} (900x...|...x900)\.(png|jpe?g|gif)
RewriteCond %{HTTP_COOKIE} ^(.*;\ )?(window_resolution=(640))(;\ .*)?$ [NC]
RewriteRule full/(.*) /responsive/cache/480/responsive/$1 [L]
RewriteCond %{REQUEST_URI} (.*)(900x...|...x900)\.(png|jpe?g|gif)
RewriteCond %{HTTP_COOKIE} ^(.*;\ )?(window_resolution=(.*))(;\ .*)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/responsive/cache/%3%{REQUEST_URI} !-f
RewriteRule .* /responsive/resize.php [L]
目前文件的位置如下:
/responsive/full/photo-900x500.jpg
缓存存储:
/responsive/cache/
采用以下格式:
/responsive/cache/<resolution>/<original path>
我想要文件的示例:
/responsive/cache/768/responsive/photo-900x500.jpg
理想情况下,这将与 wordpress 之类的东西一起使用,我会在其中制作这样的结构
缓存:
/cache/
原件:
/wp-content/uploads/*
例子:
/cache/768/wp-content/uploads/2012/01/test.jpg