Search code examples
cakephpnamed

CakePHP plus sign in named parameter decode as space


This is problem with value of named parameter when the value contain character + (plus).

The url is http://localhost/kidwatcher/messages/sentbox/number:+6581235251237

When I try to var_dump the named paramater (which in this case is number), character + becomes a space.

string(14) " 6581235251237"

Character + is %2B, the result is same when I change the url:

http://localhost/kidwatcher/messages/sentbox/number:%2B6581235251237

string(14) " 6581235251237"

But when I use url query string, it works.

http://localhost/kidwatcher/messages/sentbox?number=%2B6581235251237

string(14) "+6581235251237"

What's wrong with named parameter?


Solution

  • Okay, now i have solution for this problem.

    In folder app/webroot

    Edit .htaccess to

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L,B]
    </IfModule>