rack-rewrite 301与特定查询不匹配

时间:2014-01-24 12:10:01

标签: ruby-on-rails regex rack rack-rewrite

任何人都可以告诉我为什么会这样:

r301 %r{(?:images\/)(\d*.jpe?g|png|gif)$}, 'http://mybucket.s3.amazonaws.com/540x310/$1'

URI = http://www.mysite.com/images/42720.jpeg

这不是

r301 %r{(?:resized_images\/\d*x\d*\/)(\d*.jpe?g|png|gif)$}, 'http://mybucket.s3.amazonaws.com/540x310/$1'

URI = http://www.mysite.com/resized_images/560x344/77664.jpeg

两人都在Rubular工作:

http://rubular.com/r/PXHiEcoEqy
http://rubular.com/r/BfOta6YJa7

提前致谢

----------更新-------------

这是我如何使用机架重写的问题:

重写不能使用两个301查询字符串。

如果我将第一行注释掉第二行,反之亦然。

知道如何让他们都工作。

use Rack::Rewrite do
    r301 %r{(?:images\/)(\d*.jpe?g|png|gif|bmp)$}, 'http://mybucket.s3.amazonaws.com/540x310/$1'
    r301 %r{(?:resized_images\/\d*x\d*\/)(\d*.jpe?g|png|gif|bmp)$}, 'http://mybucket.s3.amazonaws.com/540x310/$1'
 end

1 个答案:

答案 0 :(得分:0)

最终答案。

我打破了第二次重定向到另一个使用Rack :: rewrite并修复了问题