0

I am trying to make a url rewrite as following:

 location /statics/ {
    alias /var/project/statics/;
 }
 location /statics/cache {
    rewrite /statics/cache/(.*?)/(.*)$ http://$host/statics/$2 last;
 }

Where URL would be as:
http://ANY-DOMAIN.com/statics/cache/1.2.5/file/path/file.js
The original file is:
http://ANY-DOMAIN.com/statics/file/path/file.js

The problem here is: URL is redirecting (changing URL) to original file. I want to prevent the redirection.

Current status:
Redirects to original URL

  • Remove host part from rewrite – Alexey Ten May 16 at 10:02
0

I found the answer by Changing the Mask URL as following:

new url: http://ANY-DOMAIN.com/cdn/cache/1.2.5/file/path/file.js
instead of http://ANY-DOMAIN.com/statics/cache/1.2.5/file/path/file.js

And the rewrite rule to be as:

location /cdn/cache {
    rewrite /cdn/cache/(.*?)/(.*)$ /statics/$2 last;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.