# Why I get "amp;" in array keys from getQueryParams?

**URL:** <https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777>\
**Category:** Questions\
**Created:** [December 18, 2023, 12:32pm UTC](https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777 "2023-12-18T12:32:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ischulz](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@ischulz](https://discourse.slimframework.com/u/ischulz)\
**Post date:** [December 18, 2023, 12:32pm UTC](https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777/1 "2023-12-18T12:32:25Z")

</div>

Hi, I use Slim with thephpleague/oauth2-server and can not get the query params correct.  
I have a ServerRequestInterface $request variable, when I use json\_encode($request-\>getQueryParams()) I get this result:

{“authorize”:“”,“amp;response\_type”:“code”,“amp;client\_id”:“myclient”,“amp;redirect\_uri”:“localhost”,“amp;state”:“1”}

The URL is:

[https://testserver.local/api/oauth2/authorize?response\_type=code&client\_id=myclient&redirect\_uri=localhost&state=1](https://testserver.local/api/oauth2/authorize?response_type=code&client_id=myclient&redirect_uri=localhost&state=1)

And .htaccess file:

RewriteEngine on  
RewriteCond %{REQUEST\_FILENAME} !-d  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ auth.php?$1 [L,QSA]

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [December 18, 2023, 1:13pm UTC](https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777/2 "2023-12-18T13:13:40Z")

</div>

It seems like the current rule is causing the issue and how your server is handling the request.

> RewriteRule ^(.\*)$ auth.php?$1 [L,QSA]

Here’s an example of how you can set up your .htaccess file to correctly pass the query parameters to your Slim 4 application:  
Example:

```auto
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

```

Also make sure that your server is properly configured and that there are no additional custom URL rewriting rules that might interfere with the query parameter handling.

I would recommend reading this:

- [Web Servers - Slim Framework](https://www.slimframework.com/docs/v4/start/web-servers.html#apache-configuration)

---

<div class="post-metadata">

**Author:** ![ischulz](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@ischulz](https://discourse.slimframework.com/u/ischulz)\
**Post date:** [December 18, 2023, 2:44pm UTC](https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777/3 "2023-12-18T14:44:17Z")

</div>

Hi Odan, thank you for the replay. If I change the .htaccess I get this array with the same URL:

{“response\_type”:“code”,“amp;client\_id”:“myclient”,“amp;redirect\_uri”:“localhost”,“amp;state”:“1”}

P.S. the PHP $\_GET variable is correct: {“response\_type”:“code”,“client\_id”:“myclient”,“redirect\_uri”:“localhost”,“state”:“1”}  
but oauth2-server uses getQueryParams and don’t work properly…

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [December 18, 2023, 3:51pm UTC](https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777/4 "2023-12-18T15:51:07Z")

</div>

It seems that the “amp;” prefix is being added to each query parameter, which is not expected behavior. I guess the problem is somewhere in the request handling process, these entities are not being properly decoded. Can you provide more details, such as the installed PSR-7/PSR-15 packages and other installed Middlewares?

---

<div class="post-metadata">

**Author:** ![ischulz](https://avatars.discourse-cdn.com/v4/letter/i/ad7895/32.png) [@ischulz](https://discourse.slimframework.com/u/ischulz)\
**Post date:** [December 19, 2023, 9:25am UTC](https://discourse.slimframework.com/t/why-i-get-amp-in-array-keys-from-getqueryparams/5777/5 "2023-12-19T09:25:39Z")

</div>

Ok, it work now. That was a conflict with WHMCS (I built it as a WHMCS module). Composer somehow used the modules from the WHMCS vendor directory. If I separate that from WHMCS then it works.
