Multiple Invocations of IndexController when requesting resource files

Hey everyone, quick question with a small issue that I am running into. It would seem that I have an issue with my htaccess setup, as the indexAction on my IndexController is being invoked when it is trying to load resource files. Here is the basic structure of the app


htaccess-1 has the following

Options -MultiViews
RewriteEngine on
RewriteRule  ^$ public/    [L]
RewriteRule  (.*) public/$1 [L]

htaccess-2 has the following

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

So the problem is that when I load the index page the controller runs 4 times. Once for the request when it should, but then also for /public/css/bootstrap.min.css, /favicon.ico and /public/css/font-awesome.min.css.

My thinking is that it should only run once, and Apache should see "hey, those files exist let me just send them" but maybe I am missing something. This is on a Linux box, PHP 5.5, Apache 2.4. the page looks fine, so it is loading the css files but invoking the IndexController each time.

What did I miss?

I stand corrected... apparently they are not loading properly. I am getting these errors:

Phalcon\Mvc\Dispatcher\Exception: CssController handler class cannot be loaded

So at least I have some place to start looking.


Hey Will,

I was about to say sounds so much like the files have not been found, that it is worth checking a browser dev tools network log, to see what is actually coming back. For what it is worth, your ht access looks correct.

Easy to miss, check if changing the url to this helps 'css/font-awesome.min.css'


Actually I found the issue.. my own stupidity. I had the CSS file separate when I started but then combined them into a single CSS file. So it was loading that CSS file but the other two (bootstrap.min.css and font-awesome.min.css) didn't exist on their own. That also explains why it appeared that the CSS file was loading properly even though I was getting that error.

I am assuming I can handle these types of "not found" errors within Phalcon but I'll look into that later. Until then, false alarm everyone... sorry about that :)