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

public/index/index not found

I've always developed using a WAMP stack and am in the process of learning how to do the same thing in Linux (Ubuntu 14.04). So I suspect my problem is related to how I've set up Apache and/or virtual hosts.

Here's my virutal host file located at /etc/apache2/sites-available/mysite.conf:

<VirtualHost *:80>
    ServerName mysite

    ServerAdmin [email protected]
    DocumentRoot /var/www/mysite

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/mysite/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

Whenever I go to https://mysite/index, https://mysite/index/index or https://mysite/index/login I get a 404 error, but not when I go to https://mysite or https://mysite/articles. I verified that both mod_rewrite and Phalcon are enabled, and I made sure mysite was in my hosts file. I have an IndexController and an ArticleController in app/controllers.

Here's the file at /var/www/mysite/.htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public/ [L]
    RewriteCond %{REQUEST_URI} !^/forums.*
    RewriteRule (.*) public/$1 [L]


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



try {

    $config = new Phalcon\Config\Adapter\Ini('../app/config/config.ini');

    $loader = new Phalcon\Loader();


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

    $di->set('config', $config);

    $di->set('db', function () use ($config) {
        return new Phalcon\Db\Adapter\Pdo\Mysql(array(
            'host' => $config->database->host,
            'username' => $config->database->username,
            'password' => $config->database->password,
            'dbname' => $config->database->dbname,
            'charset' => 'utf8'

    $di->set('session', function() {
        $session = new Phalcon\Session\Adapter\Files();
        return $session;

    $di->set('url', function () use ($config) {
        $url = new Phalcon\Mvc\Url();
        return $url;

    $di->set('view', function () use ($config) {
        $view = new Phalcon\Mvc\View();
        return $view;

    $application = new Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

} catch (Phalcon\Exception $e) {
     echo 'PhalconException: ', $e->getMessage();



use Phalcon\Mvc\Controller;

class IndexController extends Controller

    public function indexAction()

    public function loginAction()



host     = localhost
username = root
password = 
dbname   = mysite

baseUri        = /
controllersDir = ../app/controllers/
modelsDir      = ../app/models/
viewsDir       = ../app/views/