h2o/h2o

Rewrite... again, sorry!

开放

#740 创建于 2016年2月4日

 (3 条评论) (0 个反应) (0 位负责人)C (832 个派生)batch import
enhancementhelp wantedmruby

仓库指标

星标
 (10,793 个星标)
PR 合并指标
 (平均合并 23天 14小时) (30 天内合并 22 个 PR)

描述

It seems there are quite a few users who are looking for how to rewrite URLs in h2o. mruby makes it possible, but is not clear how. I quickly explain my latest challenge:

On our server, we have to map query strings to actual files on the server; and these may include blank spaces (or %20 when URL-encoded). For example: example.com/search?item=something%20and%somethingelse should get the file example.com/search/something_and_somethingelse

I read the mruby examples for h2o and the Rack specs, but I do not quite understand what I need to write to tell h2o to use a different path. I can read the PATH_INFO and QUERY_STRING environment variables, but how do I communicate the new values back to the h2o server ("look here instead of there")?

On a related note, I found a seemingly well-known gem called "rack-rewrite". And I was wondering, if this might help me with my rewrite rules, and how such a gem could be combined with my h2o server. Do you have an example somewhere?

贡献者指南