laravel not working in nginx as alias

Viewed 1449

i have a nginx webserver and i want to run multiple laravel projects on it

first project is working fine but second project only opens home and home page address is

example.com/secondproject/

but when i want to open

example.com/secondproject/foo

nginx would skip /secondproject alias and looks for requested route in first project (root of server in nginx config)

this is my config

server {
    listen 80;
    server_name example.com;
    rewrite_log on;

    location / {

        root /path/to/first-project/public;
        index index.php index.html index.htm;

        try_files $uri $uri/ $uri/index.php /index.php;

        location ~ \.php$ {
            fastcgi_pass unix:/run/php-fpm/www.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
        }

    }
    location /secondproject {

        alias /path/to/second-project/public;
        index index.php;

        location /secondproject {
            try_files $uri $uri/ $uri/index.php /index.php;
        }

        location ~ \.php$ {
            fastcgi_pass unix:/run/php-fpm/www.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
        }

    }

}

and when i replace

root /path/to/second-project/public;

instead of

alias /path/to/second-project/public;

nginx shows 403!

1 Answers
Related