[英]Phalcon + Nginx Routes / Rewrites not working
我终于在Osx上安装了Phalcon + phpfpm + nginx来工作...试图建立一个快速的REST应用程序,但我被卡住了,我相信可以通过nginx重写。
我总是收到路线不匹配的错误。
档案结构:
/myapp/
public/
index.php
app/
models/
...
的index.php
<?php
$app = new \Phalcon\Mvc\Micro();
$app->get('/api/robots', function() {
echo json_encode(['true']);
});
$app->notFound(function(){
echo json_encode(['Route Not Found']);
});
$app->handle();
Nginx配置文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
root /var/www/bmex/public;
listen 80;
server_name some.name.com;
charset utf-8;
#access_log /var/log/nginx/host.access.log main;
set $root_path '/var/www/bmex/public';
location / {
root $root_path;
index index.php index.html index.htm;
# if file exists return it right away
if (-f $request_filename) {
break;
}
# otherwise rewrite it
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?_url=/$1 last;
break;
}
}
location ~ \.php {
# try_files $uri =404;
fastcgi_index /index.php;
fastcgi_pass 127.0.0.1:9000;
include 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;
}
}
}
看来Phalcon文档是错误的...或者我遗漏了一些东西...我很快就会发现。
到目前为止,将_uri = / $ 1替换为= $ 1...。
rewrite ^(.+)$ /index.php?_url=/$1 last;
rewrite ^(.+)$ /index.php?_url=$1 last;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.