框架.管理文件夹不使用NGINX



网站上安装了两个php phalcons:

  1. /home/srv/http/example.com
  2. /home/srv/http/example.com/admin

nginx.conf的一部分:

server {
listen 80;
server_name example.com;
root /home/srv/http/example.com/public;
index index.php;
access_log off;
error_log /var/log/nginx/example.com_error.log;
location / {
    root /home/srv/http/example.com/public;
    try_files $uri $uri/ /index.php?_url=$uri&$args;
}
location ~ .php$ {
    fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/srv/http/example.com/public$fastcgi_script_name;
    include fastcgi_params;
}
location /admin {
    root /home/srv/http/example.com/admin/public;
}
location ~ /admin/.+.php$ {
    fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/srv/http/example.com/admin/public$fastcgi_script_name;
    include fastcgi_params;
}
}

以前,安装了apache。以及网站和管理文件夹工作。

现在我用nginx替换了apache。

网站http://example.com工作。但是http://example.com/admin不起作用,错误404。

请告诉我,我做错了什么?

您缺少尝试文件指令:

try_files $uri $uri/ /index.php?_url=$uri&$args;

最新更新