0

I don't get it why the mvc routes are not working.

When I access the home page, all the css and js are loaded.

"GET /css/main.css HTTP/1.1" 304

But when I access any other controller, I got:

method=GET path="/transaction/add"
[error] open() "/app/public/transaction/add" failed (2: No such file or directory)
"GET /transaction/add HTTP/1.1" 404

Here's my procfile

--Procfile--
web: vendor/bin/heroku-php-nginx public/

location / {
    # try to serve file directly, fallback to rewrite
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    # rewrite all to app.php
    rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/(app|app_dev|config)\.php(/|$) {
    try_files @heroku-fcgi @heroku-fcgi;
    internal;
}

I'm really lost here.

2
  • Sorry, I use Apache, but this seem to be contradictory : # rewrite all to app.php VS rewrite ^(.*)$ /index.php/$1 last; You may try with app.php instead of index.php, or else with public/index.php Commented Apr 5, 2015 at 12:36
  • @KyleK, just to update I have made some changes, but nothing yet. Commented Apr 6, 2015 at 11:44

2 Answers 2

1

This should work:

location / {
    # try to serve file directly, fallback to rewrite
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    # rewrite all to app.php
    rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/index\.php(/|$) {
    try_files @heroku-fcgi @heroku-fcgi;
    internal;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately I have tried this to, but I had no success. Maybe the problem is that the Procfile aren't reading my /public/index.php, but not sure yet.
0

Try to follow the instructions in the documentation: http://docs.phalconphp.com/fr/latest/reference/nginx.html

server {

    listen   80;
    server_name localhost.dev;

    index index.php index.html index.htm;
    set $root_path '/var/www/phalcon/public';
    root $root_path;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index /index.php;

        include /etc/nginx/fastcgi_params;

        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}

5 Comments

I did and I got "Mod-Rewrite not enabled. Please enable rewrite urls on your web server to continue". Where that was my first problem. Any idea?
What is your path (instead of /var/www/phalcon/public) and do it contains index.php?
I had executed "heroku run bash" and I saw that the path is "app/public" where inside I have the index.php. Just to be clear app folder max root that i can get, there's no folder with the project named inside of it.
app may be the FTP root but not the machine root, you must replace /var/www/phalcon/public with the absolute public path, display dirname(__FILE__) to get it.
same thing: "/app". Any other idea?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.