路由器不工作(Heroku+Nginx+PHP Phalcon)



我不明白为什么mvc路由不起作用。

当我访问主页时,所有的css和js都被加载了。

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

但当我访问任何其他控制器时,我得到了:

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

这是我的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;
}

我在这里真的迷路了。

这应该有效:

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;
}

请按照文档中的说明进行操作: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;
    }
}

相关内容

  • 没有找到相关文章

最新更新