Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my file on image folder (http://domain.com/images/myfile.jpg) has been accessed by some websites using http://domain.com/images/myfile.jpg?bla=blabla. how to redirect http://domain.com/images/myfile.jpg?bla=blabla to http://domain.com/images/myfile.jpg via nginx?

Thank in advanced

Found it

location ~ ^/images {
        if ($is_args != "")
{
rewrite ^ $uri? permanent;
}
}
share|improve this question
    
If it's about caching, you could have /images use a different cache-key (without the query args). –  BraveNewCurrency May 11 '13 at 15:08
    
would you please give example? –  imastar May 12 '13 at 1:37
    
location ~ ^/images { proxy_cache_key $scheme$proxy_host$uri; } # don't use $args when checking cache. –  BraveNewCurrency May 18 '13 at 3:13

1 Answer 1

But for what? The file myfile.jpg the file will be opened with any parameters, added after ? in uri. Anyway, 404 will not raised. ?bla=blabla not part of path to file myfile.jpg on disk for nginx in this case. It's just a variable $args in terms of nginx config.

share|improve this answer
    
I've got about 500 hits/second using ?bla=blabla and it not served from cache. So i think if it will redirect to myfile.jpg my server resource will not get problem –  imastar May 10 '13 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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