Reputation: 118
I'm having a problem with my rewrite rule. It doesn't include folders in the rewrite path. For example:
/randomstring/app.js
rewrites to /var/www/CDN/Dev/App/app.js
/randomstring/dashboard/app.js
rewrites to /var/www/CDN/Dev/App/app.js
but it should rewrite to /var/www/CDN/Dev/App/dashboard/app.js
I don't understand why it doesn't work. (.*)
matches everything but a dot if I'm not mistaken so why doesn't it include the dashboard/
part?
location ~* (css|js)$ {
rewrite ^/([^/]*)/(.*).(css|js)$ /$2.$3 ;
root /var/www/CDN/Dev/App;
}
Upvotes: 1
Views: 109
Reputation: 14374
I see no reason to use rewrite here. Alias should be enough
location ~* /[^/]+(/.+\.(css|js))$ {
alias /var/www/CDN/Dev/App/$1;
}
Upvotes: 1
Reputation: 478
location ~* \.(css|js)$ {
rewrite ^/([^/]+)/(.+)\.(css|js)$ /$2.$3 ;
root /var/www/CDN/Dev/App;
}
Upvotes: 1