We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon PHP Project not mapping (server showing directory view)

I'm in the early stages of migrating a website into a Phalcon PHP framework. However I've stumbled on the first problem.

I've set the Phalcon project up all fine as specified by various tutorials. I've checked to see my server has Phalcon installed which it does and I've uploaded the project into the /www directory. However now when I browse to the URL instead of getting the nice rendered webpage, I literally just get a directory view of my server (Screenshot 1). Even when I dig into the directory of my Phalcon project it still only goes into the directory view (Screenshot 2). It is only when I browse to /phalcon-project/public that it finally recognises and renders the index from the Controllers and Views via the bootstrap index.php in the public directory (Screenshot 3).

Any ideas on why it's not mapping? Note, as you can see in my top level (/www) I have 2 directories; let's call them /phalcon-project and /other-website as I have another site running from there (no PHP frameworks on that site, just a plain boring old static site) my URL www.phalcon-project.com maps to the /www directory and my url www.other-site.com maps to /www/other-site... I don't see that this should be causing an issue, but could it possibly be that, or something else?

Screenshot 1:

Screenshot 1

Screenshot 2:

Screenshot 2

Screenshot 3:

Screenshot 3



145.0k
Accepted
answer
edited Oct '16

You need to add some rewrite ro rewrite urls to /pubic/index.php in apache .htaccess or nginx propiate vhost conf

Thanks! I solved it by adding 2 .htaccess files. The first one, put in /www with this:

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

And the second one I put in /www/phalcon-project/public with this in:

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