Php Nginx。拉雷维尔。如何在子文件夹中设置多个端点

Php Nginx。拉雷维尔。如何在子文件夹中设置多个端点,php,laravel,nginx,nginx-location,Php,Laravel,Nginx,Nginx Location,我有这样一个项目结构 /public/laravel\u app/index.php-laravel索引文件 /public/index.php-CraftCMS索引文件 我想在加载CraftCMS应用程序 https:// 以及位于https:///laravel_app 这是我的vhost.conf server { listen 443 ssl; index index.php index.html; root /var/www/public; ssl

我有这样一个项目结构

/public/laravel\u app/index.php-laravel索引文件

/public/index.php-CraftCMS索引文件

我想在加载CraftCMS应用程序

https://

以及位于
https:///laravel_app

这是我的
vhost.conf

server {
    listen 443 ssl;

    index index.php index.html;

    root /var/www/public;

    ssl_certificate       /var/www/docker/certs/nginx.crt;
    ssl_certificate_key   /var/www/docker/certs/nginx.key;

    location / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}
我已经浏览了几乎所有相关的SO问题,并尝试了很多东西,所以,如果可能的话,请发送与我的配置相关的建议

我不是一个系统管理员,我是一个Apache用户(在那里,它以这种方式工作,没有任何调整),所以如果我遗漏了一些明显的东西,我很抱歉。

更改

location / {
    try_files $uri /index.php?$args;
}


添加
$uri/
会告诉nginx查找具有uri名称的目录。

我认为您应该进行2次url重写,因为
laravel\u app
有自己的
index.php
用于重写

server {
    ...

    root /var/www/public;

    ...

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location /laravel_app {
        try_files $uri $uri/ /laravel_app/index.php?$args;
    }

    ...
}

希望这能起作用

为您的CMS重写url是否工作正常?因此,只有Laravel url重写被破坏。或者两者都不是作品?@DharmaSaputra它不是在加载拉维。我找不到终点。nginx正在通过
/public/index.php
@DharmaSaputra传递所有信息,或者我可以通过更改
根/var/www/public来制作工作Laravel
root/var/www/public/laravel\u app,但我不能使两者都起作用。谢谢,但它不起作用。它向我显示了一个CraftCMS错误页面,所以它正在加载
/public/index.php
哈利路亚!!(非常感谢)如果我能帮助你,请尽管问)
server {
    ...

    root /var/www/public;

    ...

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location /laravel_app {
        try_files $uri $uri/ /laravel_app/index.php?$args;
    }

    ...
}