Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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'd like to redirect to These domains are on two different servers.

This is what I've tried but it does not work:

if ($http_referer ~* ( ) {
return 301;


if ($http_referer ~* ( ) {
rewrite ^ permanent;

These two ways are not working, when I go to I stay on but... without the CSS... And I am not redirected to

Any help appreciated.

share|improve this question
up vote 1 down vote accepted

Add new server section to your nginx config file

server {
    listen          80;
    rewrite         ^ permanent;

and all visitors of will be redirected to second site immediately.

share|improve this answer
It works!! Thanks mate! – Emmanuel Jan 16 '13 at 8:39

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.