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.

2 phalcon projects on subdomain not working no mapping

I have one website, let's call it, which is located on the server at /home4/username/public_html/. This site is running Phalcon PHP with no issues at all.

I have also made a subdomain, let's call it, and used cPanel to set the route for the subdomain to /home4/username/testsite/. This is where the problem is.

Both /public_html and /testsite have their own .htaccess files, and in each directory there is a phalcon project, the /public_html directory containing the project folder /public_html/main and the /testsite containing the project folder /testsite/test.

The file structure of the server with the two projects is as follows:

|---- username/
       |---- public_html/
       |       |---- .htaccess
       |       |---- main/
       |              |---- app/
       |              |     |---- controllers/
       |              |     |      |---- indexController.php
       |              |     |---- views/
       |              |     |      |---- index.phtml
       |              |     |---- models/
       |              |---- public/
       |                     |---- .htaccess
       |                     |---- index.php
       |---- testsite/
              |---- .htaccess
              |---- test/
                     |---- app/
                     |     |---- controllers/
                     |     |      |---- indexController.php
                     |     |---- views/
                     |     |      |---- index.phtml
                     |     |---- models/
                     |---- public/
                            |---- .htaccess
                            |---- index.php

The .htaccess files are as follows:

test site:

<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteRule  ^$ test/public/    [L]
        RewriteRule  ((?s).*) test/public/$1 [L]

main site:

<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteRule  ^$ main/public/    [L]
        RewriteRule  ((?s).*) main/public/$1 [L]

And testing the test site locally via XAMPP it works fine (currently just a very VERY simple Phalcon test page). But when I upload the exact same site to the server phalcon errors with: PhalconException: IndexController handler class cannot be loaded

And the stack trace for the error is: #0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('IndexController...', 2) #1 [internal function]: Phalcon\Dispatcher->_dispatch() #2 [internal function]: Phalcon\Dispatcher->dispatch() #3 /home/username/testsite/test/public/index.php(31): Phalcon\Mvc\Application->handle() #4 {main}

The dispatch index.php file for the (non-working) test subdomain site contains the following (but note, this file works perfectly on a local XAMPP server, only on the remote shared server does it not work):

    try {
      //Register an autoloader
      $loader = new \Phalcon\Loader();

      //Create a DI
      $di = new Phalcon\DI\FactoryDefault();

      //Setup the view component
      $di->set('view', function(){
        $view = new \Phalcon\Mvc\View();
        return $view;

      //Setup a base URI
      $di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        return $url;

      //Handle the request
      $application = new \Phalcon\Mvc\Application($di);

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

    } catch(\Phalcon\Exception $e) {
      echo "PhalconException: ", $e->getMessage();
      echo "<br /><br /><strong>Trace Stack</strong>: ", $e->getTraceAsString();

Now this is baffling, as I said, there's no reason code wise the Phalcon project is wrong, as it works fine locally. So the only thing I can think of is somehow the routing of the subdomain is screwing things up. However I have also tried putting a simple <?php phpinfo() ?> inside /test/public/php_info.php which works perfectly fine when accessing via so the .htaccess file is routing as it should.

Is there something wrong with the way things are being routed in phalcon, seen as the test site can't seem to find the controllers folder. Or can phalcon only run one project on one server? I honestly have no idea why it doesn't work.

Thanks, although whilst this is currently a subdomain I also have a seperate domain (e.g. which maps to a /other on this shared server which is the real purpose of hosting this. So I'm not sure I want to host multiple modules in one phalcon projects... Is it not possible to run 2 sites from 2 different directories on the server as 2 seperate phalcon projects??

no idea if this would help you


well i dont know the story ( and the target ) but i am 90% sure what you have in mind is wrong. And you should not be doing it. I guess the router is depending on the domain, but i am not sure.

do the 2n project on complatly different domain and proxy pass it with apache / nginx

edited Jun '17

I had the same worries i solved it in index.php

define('BASE_PATH', dirname(__DIR__));
      BASE_PATH .  '/../app/controllers/',
       BASE_PATH . '/../app/models/'

Dump BASE_PATH to see and complete the path


So it turned out to be something really simply stupid. For some reason using phalcon locally via XAMPP on Windows allowed me to use indexController.php as a controller name. However, when uploaded to the Apache server the name needed to be capitalised in full camel case to IndexController.php to work.

edited Jun '17

One more Windows fu## up. Well, not to blame Windows directly but rather (mis)understanding of the basics. And we do have containers and stuff these days with one main goal - to simulate production environment and to avoid this kind of issues.


Windows file names are semantic, therefore case insensitive. indexController.php and indexController.php mean the same thing, as you would expect from them having the same spelling. Linux does not have that feature in the default file system.

This is one of the really difficult things to explain to Web site owners. Most of the URL is defined as case insensitive but the path part depends on the file system used. Whoever defined URLs forgot to define the whole URL as case insensitive.