We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

$_GET-variables ignored.

Hello again.

Now I've run into a problem I've never seen before. If I go to https://localhost?test=test and in my ControllerBase::initialize()-method and run:

var_dump($_GET);

I get:

array(1) {
  'test' =>
  string(4) "test"
}

But if I go to: https://localhost/user/loginWithFacebookCode?test=test and run the same code, I get:

array(1) {
  '_url' =>
  string(27) "/user/loginWithFacebookCode"
}

It seems that the $_GET-variables can only be picked up on the start page... If a route is executed, they're no longer available.

I've searched everywhere; Apache, PHP, Phalcon, never seen this anywhere. Any ideas as of why my $_GET["test"] doesn't exist?

Additional info:

  • I use the ACL from the Phalcon "Invo" example project where I've tried placing the methods / controller in both public and user visibilities (and made sure to empty the persistant variable).
  • OS: OSX Mountain Lion
  • Server: Apache2
  • Engine: PHP 5.4.11

Anyone know where to look?

Thanks!

// dimhoLt



22.6k

I found it; the standard Phalcon htaccess has the following rule:

RewriteRule (.*) index.php?_url=/$1 [NC,L]

Which naturally erases all additional $_GETs from the request. I'll just parse them out of the $_SERVER["REQUEST_URI"] instead. https://global3.memecdn.com/i-am-a-disgrace-to-the-clan_o_1110942.jpg

Thanks for any views, and hope this helps someone else.

Regards, dim



4.5k

echo $this->request->getQuery('test');

Try.

RewriteRule (.*) index.php?_url=/$1 [NC,L,QSA]

if you need all request parameters as $_GET variables.



4.5k

RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] this is me.