Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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 "http://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!!!