路由器不工作(Heroku + Nginx + PHP Phalcon) [英] Router not working (Heroku + Nginx + PHP Phalcon)

查看:176
本文介绍了路由器不工作(Heroku + Nginx + PHP Phalcon)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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

 GET /css/main.css HTTP / 1.1304 

$ $ $ $ $ $ $ $ $ $ $>方法=>

GET路径=/ transaction / add
[错误] open()/ app / public / transaction / add失败(2:没有这样的文件或目录)
GET / transaction / add HTTP /1.1404

这是我的procfile

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

位置/ {
#尝试直接提供文件,回退以重写
try_files $ uri @rewriteapp;
}

位置@rewriteapp {
#全部重写为app.php
重写^(。*)$ /index.php/$1 last;
}

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

我真的迷失在这里。

  location / {$ b $ 

b#尝试直接提供文件,fallback重写
try_files $ uri @rewriteapp;
}

位置@rewriteapp {
#全部重写为app.php
重写^(。*)$ /index.php/$1 last;
}

location〜^ / index\.php(/ | $){
try_files @ heroku-fcgi @ heroku-fcgi;
内部;
}


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.

解决方案

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

这篇关于路由器不工作(Heroku + Nginx + PHP Phalcon)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆