我有这样一个项目结构
<root>/public/laravel_app/index.php — Laravel index file
<root>/public/index.php — CraftCMS index file
我想加载 CraftCMS 应用程序在
https://<domain>
和 Laravel 应用程序位于 https://<domain>/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 用户(它以这种方式工作,无需任何调整),所以如果我遗漏了一些明显的东西,我深表歉意。
最佳答案
我认为你应该重写 2 个 url,因为 laravel_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;
}
...
}
希望这能行得通
关于php - Nginx。拉拉维尔。如何在子文件夹中设置多个端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47012691/