Quantcast
Channel: Active questions tagged 22.04 - Ask Ubuntu
Viewing all articles
Browse latest Browse all 4439

Nginx rewrite rule for CSS and JS files

$
0
0

I've been using for a while .htaccess in Apache and now, when using Nginx need to learn new writing.

I've been using in .htaccess:

RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]

It rewrite ...css/style.1234567890.css to css/style.css.

Now, in Nginx I'm trying this:

location ~* \.(js|css)$ {    rewrite ^(.*)\.\d{10}\.(css|js)$ $1.$2 break;}

or

location ~ ^(.*)\.\d{10}\.(css|js)$ {    rewrite ^(.*)\.\d{10}\.(css|js)$ $1.$2 break;}

But after sudo nginx -t there is still unknown directive "10}\.(css|js)$" error.

What I'm doing wrong?


Viewing all articles
Browse latest Browse all 4439

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>