1

我在 WordPress 主题上使用Adaptive-Images,我也想将一些正常比例的图像重定向到双倍比例/大小的图像,以支持 HiDPI/Retina。但是RewriteRule来自 Adaptive-Images 将覆盖 HiDPI RewriteRule

两个脚本单独工作都很好,但不能一起工作。我可以RewriteRule通过 Adaptive-Images 从主图像中排除一些图像尺寸吗?或者任何其他解决方案?

谢谢奥尼
_

我的.htaccess样子

<IfModule mod_rewrite.c>
RewriteEngine On

# Adaptive-Images
# http://adaptive-images.com
RewriteCond %{REQUEST_URI} cms/assets
RewriteRule \.(?:jpe?g|gif|png)$ cms/wp-content/themes/roots/inc/adaptive-images.php

# HiDPI
# http://cup.wpcoder.de/wordpress-hidpi-bilder/ 
RewriteCond %{HTTP_COOKIE} HTTP_IS_HIDPI
RewriteCond %{DOCUMENT_ROOT}/$1-554x380.$2 -f
RewriteRule ^(cms/assets.+)-277x190\.(jpe?g|png)$ $1-554x380.$2 [L] 

</IfModule>
4

1 回答 1

0

您是否尝试过交换两个规则的顺序并[L]在自适应图像规则中添加一个标志?

<IfModule mod_rewrite.c>
RewriteEngine On

# prevent any looping
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

# HiDPI
# http://cup.wpcoder.de/wordpress-hidpi-bilder/ 
RewriteCond %{HTTP_COOKIE} HTTP_IS_HIDPI
RewriteCond %{DOCUMENT_ROOT}/$1-554x380.$2 -f
RewriteRule ^(cms/assets.+)-277x190\.(jpe?g|png)$ $1-554x380.$2 [L] 

# Adaptive-Images
# http://adaptive-images.com
RewriteCond %{REQUEST_URI} cms/assets
RewriteRule \.(?:jpe?g|gif|png)$ cms/wp-content/themes/roots/inc/adaptive-images.php [L]

</IfModule>

看起来如果请求是专门针对277x190大小图像的,那么 HiDPI 规则将首先匹配。否则,自适应规则将匹配。

于 2013-10-08T07:28:20.907 回答