Server Fault is a question and answer site for system and network administrators. 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'm working on a new top-level domain, and redirect visitors of the new domain to the old one, except for my own work on the staging server:

I have a rule that rewrites the host if you don't hit the staging server, which works like a bomb.

if ($host != '') {
  rewrite ^/(.*)$$1 permanent;

the problem is that some callback from another site we are using is hitting At the moment that is redirecting to the site, but I really want it to redirect to the staging server.

I have added the following ontop of the previous bit of code:

location ~ /s/ {
  rewrite ^/(.*)$$1 permanent;

But this doesn't seem to catch the callback, i.e. if I visit it still redirects to

Can anyone describe how to nest those location and if statements, please?

Thank you!

share|improve this question
up vote 0 down vote accepted

I think your doing it right, and are most likely seeing cache problems while your working on it...

Change "permanent" to "redirect" for now, and also add a line like: expires epoch;

while your testing to stop the browser from caching



share|improve this answer
thanks, i think that's how i solved the issue but it's now a while ago. – rdrey Jul 27 '10 at 0:18

Your Answer


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.