0

I'd like to redirect www.mydomain.com to www.mydomain2.com/try.html. These domains are on two different servers.

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

if ($http_referer ~* (www.mydomain.com) ) {
return 301 http://www.mydomain2.com/try.html;
}

OR

if ($http_referer ~* (www.mydomain.com) ) {
rewrite ^ http://mydomain2.com/try.html permanent;
}

These two ways are not working, when I go to mydomain.com I stay on mydomain.com but... without the CSS... And I am not redirected to mydomain2.com/try.html

Any help appreciated.

1 Answer 1

1

Add new server section to your nginx config file

server {
    listen          80;
    server_name     mydomain.com www.mydomain.com;
    rewrite         ^ http://www.mydomain2.com/try.html permanent;
}

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .