Hello guys, I don't know if this as been already talked or documented but i will post it to help any new phalcon user that encounter the same problem.
It's not a Phalcon bug or internal problem, but an enviroinment config problem. I think it should be included in documentation to avoid to loose time. The problem is simple and comes out if you : - are on Apache with mod_rewrite - have a controller named like IndexController (or something that match the default php file loaded by the server) (and is more evident if you:) have a Router config that automatically match controller/action in the url.
Problem: you could never request an url like "host/index/youraction" as mod_rewrite and actual default rewriting rules in the .htaccess provieded with Phalcon sample projects are broken for this case. It will result in a 404 error (not managed by Phalcon)
Explication of the problem: I'm pasting here the comment i've included in my BaseController to remind me what to not do
/** * Pay attention to the name of the controller! * It should never be "IndexController" or any name that match the DEFAULT php file loaded by the server (eg. index.php) * because mod_rewrite catch and confuse the 'index' word in the url as filename * and breaks all the rules stripping it from the url requested. * eg. if we have * $router-add("/:controller/:action", array( * 'controller' = 1, * 'action' = 2, * )); * and request the url <a href="http://host/index/test">http://host/index/test</a> to request the testAction in IndexController * it wont work (causing a pure 404 error neither ever sent to the framework) as mod_rewrite will * parse the url in subsequent internal redirect with this steps: * 1) /public/index/test (as for the root .htaccess) * 2) (public/)index.php/test (as for the public/ .htaccess) <--- PROBLEM!! * as you can see the /index/ part of the requested url is stripped off the url between redirects as * it is recognized as the default index.php file in the current dir *(mod_rewrite log show "strip per-dir prefix" as the culprit transformation) * this cause the RewriteCond in public/.htaccess to be matched (by mistake) as follow: * pattern='!-d' = matched * pattern='!-f' = not-matched <---- HERE THE CONSEGUENCE!! * because it find index.php IS AN EXISTING FILE (as it is) and try execute it directly with wrong parameters * instead of executing the next rewriting rule (that couldn't be executed as the last of the condition is NOT MATCHED). * On the contrary, the default correct rewriting should transform and redirect the original url to * public/index.php?_url=index/test * */
My Workaround for now, before investigate more on a definitive solution on rewriting rules, is to rename the IndexController to something like "HomeController".
Hope this help.