PHP script does not decode URL parameters in $ _REQUEST [] (% 20 present) after deployment before 5.2.4

I developed a PHP script that uses $ _REQUEST [] superglobal. A typical client request may consist of:

http://host.name/socnet/add.php?shortid=1&author=NewUser2&comment=Dad%20dad%20dad

This URL is rewritten by Apache in my production environment to the equivalent https: // URL according to the following rewrite rule:

RewriteRule ^socnet/add.php(.*) https://%{SERVER_NAME}/socnet/add.php$1 [R,L]

During development with PHP 5.3.2 and debugging using NetBeans, everything works as expected $_REQUEST['comment']="Dad dad dad"

However, when I deployed to my VPS host environment running PHP 5.2.4 and which was rewriting the URL described above ... $_REQUEST['comment']="Dad%20dad%20dad"

So it looks like the $_REQUEST['comment']url is not decrypted, as expected in 5.2.4, and my rewrite rule

Any ideas as to why this is happening and a reasonable workaround would be greatly appreciated. Is this a problem with the PHP version or something more subtle? Interested in hearing from everyone who encountered this problem during deployment before and how they resolved it.

+3
source share
1 answer

I suspect that mod_rewrite encodes it, which causes it to be encoded twice. I have not tried this, but instead of matching (. *) Try changing [R,L]to [R,L,QSA]. QSAmeans a string with a query string.

EDIT

The correct option found by landstatic itself NE, which does not mean that it does not slip away.

+1

Source: https://habr.com/ru/post/1755796/


All Articles