I have problem configuring laravel configuration that would run from /api/ segment of main domain. Idea is to serve at subdomain.domain.com main Angular aplication and in subdomain.domain.com/api/ laravel php server configuration.
UPDATE #1
I have managed to run laravel from /api/ segment with this configuration
server {
listen 80;
server_name subdomain.domain.com;
root /var/www/subdomain.domain.com/client/monkey/dist;
access_log /var/www/subdomain.domain.com.access.log;
error_log /var/www/subdomain.domain.com.error.log;
rewrite_log on;
index index.php index.html;
location / {
root /var/www/subdomain.domain.com/client/monkey/dist;
index index.html;
if (!-e $request_filename){ # handles page reload
rewrite ^(.*)$ /index.html break;
}
}
location /api/ {
root /var/www/subdomain.domain.com/server/;
try_files $uri $uri/ /api/index.php$is_args$args;
}
location ~ /api/.+\.php$ {
root /var/www/subdomain.domain.com/server/;
rewrite ^/api/(.*)$ /$1 break;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
fastcgi_param MONKEY_ENV production;
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
# fastcgi_split_path_info ^(.+\.php)(.*)$;
}
}
Only problem that has left is that when i'm using subdomain.domain.com/api/segment1/segment... then I need to add in routes.php
Route::group(['prefix' => 'api'], function () {
// my routes settings
});
As laravel is starting from suddomain.domain.com/ as root path. How can i rewrite /api/ so that laravel takes /api/ as routing starting point ?
/api? If not then why are you not making/apithe public folder for Laravel?