Question

I'm a beginner with Phalcon and I just can't figure out what's happening. I'm working with OAuth2.0 and I'd like to get the authorization code from the query parameter.

As stated in the documentation, I have to use $request->getQuery().The thing is, it gives me something completely different.

The URI is like this:

https://my.site/controller/method?foo=bar

Using var_dump($request->getQuery()); returns the following:

array(1) { ["_url"]=> string(12) "/controller/method" }

This seems like the URL part in the Apache .htaccess RewriteRule that is shown in the Phalcon examples. (RewriteRule ^(.*)$ /index.php?_url=/$1 [P,L] (I changed the flags only))

What am I doing wrong?

Was it helpful?

Solution

You can add the [QSA] flag to the RewriteRule to retain query strings.

From the docs:

When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

Something like this:

RewriteRule ^(.*)$ /index.php?_url=/$1 [P,L,QSA]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top