i had to modify an NGINX configuration to allow getting the static files from a different folder.
server {
listen 80;
server_name app.test;
root "/home/vagrant/app/public";
index index.html index.htm index.php;
charset utf-8;
location ~ (.*.css|.*.js|.*.png|.*.jpg|.*.gif|.*.svg) {
alias /home/vagrant/app$request_uri;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
The part i added was the location .*.css
etc where it's basically matching those file extensions and if it finds them it serves them directly from a particular folder other that the main project folder.
Otherwise i want it to send PHP requests to the main project application, hence the location /.
It works alright, but the problem is that it shows the URL like http://app.test/index.php/
whenever i try to navigate to http://app.test/
, it wasn't doing that before i added the alias, and so i'm wondering if the alias could be the cause of it and how can i get rid of the added index.php
. Thank you in advance :)