We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

404 error with REST API

  1. I have following structure for my REST API:


I do a proxying of all requests in the client with htaccess to Server.

When i send requests via GET like "https://localhost/REST/Client/api/shop/cars" i always get 404 error. (in my server .htaccess i point urls to index file like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /localhost/REST/Server/api/shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]

here is my index.php file:


    $loader = new \Phalcon\Loader();

    __DIR__ . '/models/'

    $app = new \Phalcon\Mvc\Micro();

    // Getting All cars

    $app->get('/cars', function() use ($app) {

     $phql = "SELECT * FROM Cars ORDER BY make";
    $cars = $app->modelsManager->executeQuery($phql);

     $data = array();
    foreach( $cars as $car){
        $data[] = array(
            'car_id' => $car->getCarId(),
            'make' => $car->getMake(),
            'model' => $car->getModel()

    echo json_encode($data);

    $di = new \Phalcon\DI\FactoryDefault();

    // Db settings
    $di->set('db', function(){
    return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
        "host" => "localhost",
        "port" => 3307,
        "username" => "root",
        "password" => "",
        "dbname" => "carshop"

    $app = new \Phalcon\Mvc\Micro($di);


Please advise!


There was an htaccess error, Phalcon is good!!!