Add 301 redirect for Link item

This commit is contained in:
Wen-Tien Chang 2010-01-28 17:24:47 +08:00
parent aab1199aee
commit ce63c53605
1 changed files with 5 additions and 3 deletions

View File

@ -13,11 +13,13 @@ class RerouteMiddleware
parsed_entry_name = $1 parsed_entry_name = $1
entry = Item.find_by_name( parsed_entry_name ) entry = Item.find_by_name( parsed_entry_name )
case entry.type case entry.type.to_s
when Component : when 'Component' :
env['REQUEST_URI'] = env['REQUEST_URI'].sub!(parsed_entry_name, entry.engine_name) env['REQUEST_URI'] = env['REQUEST_URI'].sub!(parsed_entry_name, entry.engine_name)
env['QUERY_STRING'] = (env['QUERY_STRING'].blank?)? "entry_name=#{parsed_entry_name}" : "entry_name=#{parsed_entry_name}&#{env['QUERY_STRING']}" env['QUERY_STRING'] = (env['QUERY_STRING'].blank?)? "entry_name=#{parsed_entry_name}" : "entry_name=#{parsed_entry_name}&#{env['QUERY_STRING']}"
when 'Link' :
return [301, {'Location' => entry.url }, ['See Ya!']]
end end
@app.call(env) @app.call(env)