Re: [users@httpd] mod_rewrite decodes %20 -> 400 bad request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ogjunk-httpd1@xxxxxxxxx wrote:
One more thing....

--- André Malo <nd@xxxxxxxxx> wrote:

* <ogjunk-httpd1@xxxxxxxxx> wrote:

Hi,

I "solved" this problem by substituting "%20" with "+" characters. Apparently, mod_rewrite doesn't convert "+" to spaces as it does
with
"%20".
Your "problem" is home-made. mod_rewrite always works on the
unescaped
URI-path and you're explicitly specifying by using [NE] that no
escaping
on the final string should be done. So you end up with unescaped
characters
in this final string (not only spaces will be a problem).

Just to make sure I got this - are you saying that if I remove [NE]
from the RewriteRule, then mod_rewrite will NOT convert %20 in a
requested URI to a space?

NE=no escape. mod_rewrite will not escape the output, meaning the substitution /bar?arg=P1\%3dTest would usually become /bar?arg=P1%253dTest (% is encoded into %25, and the NE-Flag prevents this).

Try this:
  http://simpy.com/user/otis/search/apache%20httpd

That URL is handled by the following RewriteRule:

RewriteRule ^/user/(.*)/search/(.*)$ /simpy/User.do?username=$1&q=$2 [P,env=URR:1]

What I also asked you about in the newsgroup alt.apache.configuration: Why are you using the proxy-Flag ([P]). There is nothing to proxy here, because no protocol + host is given. So why don't you use just

RewriteRule ^/user/(.*)/search/(.*)$ /simpy/User.do?username=$1&q=$2 [L,env=URR:1]

I tested both rules an apache 1.3.33, the one with the P-Flag returns a 400, without a 200.

This results in the following request under the hood:
GET /simpy/User.do?username=otis&q=apache httpd HTTP/1.1" 400 369 "-"
"-"
                                   ^^^^^^^^^^^^

Usually the original request should be logged, /user/otis/search/apache httpd, not the one you're rewriting to. I think it's caused by the P-Flag.

--
Robert


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux