I have to update a nginx host so all requests to an alias are rewritten to /alias_path/index.php?q=$uri
. But now all the assets are no longer available.
This is my current configuration. And I'm getting closer, but when I am uncommenting the last location, the assets are no longer available.
location /csv-import {
alias /var/www/csv-import/public;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
try_files $uri $uri/ =404;
#location ~ ^/csv-import/(.*)$ {
#alias /var/www/csv-import/public;
#try_files $uri $uri/ /csv-import/index.php?q=$1;
#}
error_log /var/log/nginx/csv-import.error.log;
access_log /var/log/nginx/csv-import.access.log;
}
The file I wan't to reach is /var/www/csv-import/public/index.php
. All Urls like example.com/csv-import/some/url
should be rewritten to example.com/csv-import/index.php?q=some/url
but assets like example.com/csv-import/css/app.css
should be available under /var/www/csv-import/public/css/app.css
.
I'm shure there is a solution that works perfect but I couldn't come up with it.