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

We're transitioning from a set of locations of the form: example.com/app1 where we will do a redirect to /app2.

However, we want to keep some URIs for app1 active, e.g., example.com/app1/111 and example.com/app1/222 should NOT redirect.

How should this be done? The location block doesn't accept a prefix like "!~", which would make it easy, i.e.,

location !~ /app1/(111|222) {
  rewrite /app1 /app2;
}

does not work in terms of the location pattern matching.

I've tried this (as well as putting parens around everything after /app1/), but it doesn't work either:

location ~ /app1/!(111|222) {
  rewrite /app1 /app2;
}

Suggestions?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

cmiiw could you try (pls make sure the order is correct, and you may try to change the regex)

location ~ ^/app1/111$ {
  break;
}

location ~ ^/app1/222$ {
  break; 
}

location ~ ^/app1$ {
  rewrite /app1 /app2;
}
share|improve this answer
    
My simple example is to simple; I had to add a bunch of proxy-type statements into the "location ~ ^/app1/(111|222}" block. I believed I missed one of them in an earlier test. –  cjc Jan 30 '12 at 18:57

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.