Apache mod_rewrite% 2B and plus (+) signs

I use apache / mod_rewrite to re-write urls, but I am having problems with a plus sign.

The next rule.

RewriteRule ^/(.+[^/])/?$ http://localhost:8080/app/home?tag=$1 [P,L] 

AND

http://localhost/1+1 and http://localhost/1%2B2

ends as

uri=http://localhost:8080/app/home, args=tag=1+2

Thus, in both cases, the application translates the plus sign into a space so that it can no longer distinguish between spaces and signs.

If I use the “B” flag, then in both cases the + signs translate to% 2B, and the application ends with the same problem, but vice versa (both spaces and plus signs are plus signs)

Is there a way to get apache to escape% 2B correctly in the plus sign rather than a space?

I read something about mod_security, but I am not using it, so I'm not sure if there is any other security mechanism that causes this?

Any help would be greatly appreciated!

+5
1

, , . - , , Apache: mod_rewrite: Spcaes URL-, , .

, . http://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes ( Apache -.htaccess ).

, . Apache URL- , rewrite, , : http://example.com/a+b.html wouldn '

"a b.html".

PHP $_GET ( , ) , . , Apache % 2B + , + , .

, , +, , URL-, %20. , , . , .

- DIY, :

RewriteRule. * index.php [L]

, index.php, . , . , , . RewriteCond% {REQUEST_FILENAME}! -f

index.php

$uri = substr ($ _ SERVER ['REQUEST_URI'], 1);//

$qmpos = strpos ($ uri, '?');// , ,

if ($ qmpos! == FALSE) {$ uri = substr ($ uri, 0, $qmpos); }// q.m.

$decoded = urldecode ($ uri);// URL

if (! empty ($ decoded)) {$ _GET ['args'] = $decoded; }// $_GET

( - , , - ) args PHP $_GET, $_GET .

, URL- (http://example.com/) , (http://example.com/?foo=1), (http://example.com/bar) (http://example.com/bar?foo=1). , .

, PHP . , rawurldecode, .

+2

All Articles