Nginx Yii2 configuration in different folders

末鹿安然 提交于 2019-11-29 15:44:06

Further to your comment, any URI beginning with /fetch that does not match a static file within the aliased path, should be redirected to /fetch/index.php.

location ^~ /fetch {
    alias /usr/share/nginx/html/another_folder/web;

    if (!-e $request_filename) { rewrite ^ /fetch/index.php last; }

    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }

        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $request_filename;
        fastcgi_pass   127.0.0.1:9000;
    }
}

We avoid using try_files with alias because of this long term issue.

See this caution regarding the use of if.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!