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.

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 != 'staging.xxx.com') {
  rewrite ^/(.*)$ http://xxx.co.za/$1 permanent;
}

the problem is that some callback from another site we are using is hitting xxx.com/s/callback. At the moment that is redirecting to the .co.za 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 ^/(.*)$ http://staging.xxx.com/$1 permanent;
}

But this doesn't seem to catch the callback, i.e. if I visit xxx.com/s/callback it still redirects to .co.za.

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

Thank you!

share|improve this question
add comment

1 Answer

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

Best,

-Eric

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
add comment

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.