Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've came into situation where I cannot find a way around it, neither with tons googling.

valid_referers none blocked something.com;
if ($invalid_referer) {
    rewrite ^ /leech.jpg;
    expires epoch;
}

Everything works fine so far, but I want to create if referer is valid to expire max; I couldn't find how to negate if statement or create else in nginx configuration. I tried:

else {
    expires max;
}

or (notice exclamation mark)

if(!$invalid_referer){
     expires max;
}

but it doesn't work as it works in almost everywhere.

share|improve this question
up vote 3 down vote accepted

Try to make one setting default and other one turned on by condition:

expires max;

valid_referers none blocked something.com;
if ($invalid_referer) {
    rewrite ^ /leech.jpg;
    expires epoch;
}
share|improve this answer
    
if ($invalid_referer = 0) is working for me, thanks to guys from #nginx. But your solution is even better – ewooycom May 1 '12 at 17:46

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.