Issue #432 resolved

wiki/BehindApache should have info regarding mod_rewrite unescaping URI

Anonymous created an issue

Apache2's mod_rewrite unescapes path information which may generate invalid HTTP requests, specially when there's a %20 (space) char on the path. When using mod_request, it may happen that the HTTP request that CherryPy recieves have more than 2 spaces on the request line (which breaks CherryPy). A workaround to this is to add the following to your apache configuration: {{{

this cannot be on .htaccess (only on httpd.conf)

RewriteMap escape int:escape

and when writing RewriteRule:

RewriteRule ^(.*)$ http://localhost:6674/${escape:$1} [P]

(i.e., use ${escape:$1} instead of $1)

}}}

I think this should be added to wiki/BehindApache so other people may know about it. (AFAIK, this is a bug on mod_rewrite/apache since I've researched HTTP/1.1 and URI RFC's and they all state that there must be only those 2 spaces on HTTP request line, i.e., CherryPy is parsing the request line correctly and Apache is sending invalid HTTP requests). Either way, I think this workaround will help people using CherryPy under apache's modrewrite. I've only tested this on Apache2, I don't know if rewriteMap int:escape exists on older versions of mod_rewrite.

Reported by fserb@fserb.com.br

Comments (3)

  1. Log in to comment