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

Routing with russian symbol gives 404 error

I have route, which has a Russian symbol:

      $router->add(
          "#^\/group\/([a-zа-я])#u",
          [
              "controller"    => 'group',
              "action"        => 'test',
              "type"          => 1
          ]
      );

This URL opened ok

/group/d

It gives me a 404 error

/group/д

Phalcon 3.2.4 php 5.5.9



77.7k
Accepted
answer
edited Dec '17

Phalcon is using preg_match, check if that's working at all (php5.5 seems outdated to me)

preg_match('#^\/group\/([a-zа-я])#u', '/group/d', $match1);
preg_match('#^\/group\/([a-zа-я])#u', '/group/д', $match2);
var_dump($match1, $match2);

It should work - as it is PCRE feature - u flag will make pattern interpreted as UTF-8. Only if PCRE itself is outdated badly - but I doubt that can be the case with PHP 5.5.

And really - stop using 5.5. as it is EOL for 2 years already.



1.5k

It works ok

array(2) {
  [0]=>
  string(8) "/group/d"
  [1]=>
  string(1) "d"
}
array(2) {
  [0]=>
  string(9) "/group/д"
  [1]=>
  string(2) "д"
}

Phalcon is using preg_match, check if that's working at all (php5.5 seems outdated to me)

preg_match('#^\/group\/([a-zа-я])#u', '/group/d', $match1);
preg_match('#^\/group\/([a-zа-я])#u', '/group/д', $match2);
var_dump($match1, $match2);

bump... @Jurigag may have some insight

edited Dec '17

Hmmm maybe try to use newer phalcon?

$micro = new Micro();

$micro->get('#^\/group\/([a-zа-я])#u',function(){
   echo ('test');
});

$micro->handle('/group/д');

This works correctly. Same router is used both in micro and full application so it works.



1.5k

Sorry guys. That's my fault. I had a parameter:

$router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

thank you all!