Config Nginx for Laravel in a Subfolder

Laravel in a sub-directory using NGINX with preserved routing

You need to set dynamicaly and change the fastcgi_param REQUEST_URI $request_url.

Basically to remove or add (depend on your needs) the word /shop from the REQUEST_URI

You may need to remove REQUEST_URI from fastcgi_params file.

More info and example can found in

https://serverfault.com/questions/697569/rewrite-url-with-fastcgi-in-nginx

I didn't tested it so maybe some changes need to made in some lines or change the order of things...

but you can try to use something like

location /shop {
alias /var/www/shop/public;
try_files $uri $uri/ @shop;

location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI /shop$request_uri;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}

location @shop {
rewrite /shop/(.*)$ /shop/index.php last;
}

nginx: how to serve file from a subfolder of root?

Fixed adding

location /fonts {
root /var/www/prod.revisions;
}


Related Topics



Leave a reply



Submit