I have been dealing with the problem for about several hours without any success. The problem that I cannot server static files from my project.
Previously I had the following rules for the Apache server.
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
I have tried the following location rules in my nginx configuration
location ~ ^/css/?(.*)$ {
#return 200 $document_root/web/css/$1;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
#try_files $uri $uri/ /index.php =404;
try_files $document_root/web/css/$1 =404;
}
By the way #return 200 $document_root/web/css/$1;
returns the valid path.
But the request still fails.
Also I tried to use alias
as follows
location ~ ^/css/?(.*)$ {
alias /var/wwww/myproject/web/css;
# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
try_files $uri $uri/ /index.php =404;
}
The same situation 404, if I change 404 in the location above it will also return another code, accordingly location statement is reached but try_files doesn't work
Please help to solve the issue, I don't know whatever to try. Thanks