Nginx host rule does not match

I tried it for several hours, but it's hard for me to understand this.

location ~* ^\/sys\/assets\/(.*).css$ { try_files $uri $uri/ /sys/assets/stylesheets/$1; } 

I am basically trying to make css files called from /sys/assets/file.css to return to / sys / assets / stylesheets / file.css

+5
source share
1 answer

Your first group of matches is the file name without the extension, while you pass it to the last backup URL where the extension is expected.

Also, there is no point in dropping slashes. There is no special meaning.

 server { listen 80; server_name localhost; root /var/www/localhost/www; location ~* ^/sys/assets/(.+)\.css$ { try_files $uri /sys/assets/stylesheets/$1.css; } } 
+6
source

Source: https://habr.com/ru/post/1202806/


All Articles