我在/wp-content/uploads/2012/08/no-trail-picture_369.png
上传了一张图片,正如您所看到的,我有数百张图片。我希望其中包含no-trail-picture_(.*).png
的任何图片重定向到/wp-content/uploads/2012/08/no-trail-picture.png
这是我目前的非工作代码。
<IfModule mod_rewrite.c>
RewriteEngine On
RedirectMatch 301 ^/wp-content/uploads/2012/08/no-trail-picture_(.*)$ /wp-content/uploads/2012/08/no-trail-picture.png
</IfModule>
我也试过没有运气:
<IfModule mod_rewrite.c>
RewriteEngine On
RedirectMatch 301 ^/(.*)/no-trail-picture_(.*)$ /wp-content/uploads/2012/08/no-trail-picture.png
</IfModule>
还试过这次重写:
RewriteRule ^wp-content/uploads/2012/08/no-trail-picture(.*?).png$ wp-content/uploads/2012/08/no-trail-picture.png [L]
答案 0 :(得分:1)
尝试此规则:
RewriteRule ^(wp-content/uploads/2012/08/no-trail-picture)_[^.]+.png$ $1.png [L,R=302,NC]
确保上述规则高于您常用的wordpress内容(位于RewriteBase行下方)