【发布时间】:2018-04-27 07:05:11
【问题描述】:
我正在尝试在同一个域下运行两个代码库,一个静态 vue-cli 站点和一个 Laravel 后端 api。
静态站点将用于前端,这将查询 laravel 代码库。我无法从我的 laravel 网址中删除 index.php。
我的文件系统如下;
/var/www/site/frontend/dist/index.html <-- static homepage
/another.html <-- another static page
/var/www/site/backend/api/index.php <-- api access
对我的 api 的请求看起来像
/api <-- laravel landing page, only for debugging
/api/autocomplete/artist/{artistName}
/api/autocomplete/artist/{artistName}/album/{albumTitle}
我想我很接近但不是很接近,我拥有的最好的是 l Laravel 登陆页面,但是每当我添加路由参数时,我都会得到 404,下面是我的配置;
server {
listen 80 default_server;
root /var/www/site/frontend/dist;
index index.html index.htm index.php;
server_name _;
# Make index.php in /api url unnecessary
location /api {
alias /var/www/site/backend/api;
try_files $uri $uri/ /index.php?r=$is_args$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}
}
【问题讨论】: