Nginx redirect one domain to another

Posted by Bob on Server Fault See other posts from Server Fault or by Bob
Published on 2010-05-26T20:21:32Z Indexed on 2010/05/26 20:33 UTC
Read the original article Hit count: 276

Filed under:
|
|
|
|

Hello,

I have two domain's set up on my server. Domain 1 is configured with google apps so that mail.domain1.com goes to google's mail. However, I would like domain1.com to redirect to domain2.com.

Currently in my nginx.conf file

I had

server {
    listen 80;
    server_name domain2.com .domain1.com;
    rewrite ^/(.*) http://domain2.com permanent;
    root /home/demo/apps/cjl/public;
    passenger_enabled on;
    rails_spawn_method smart;
 }

When I did this Firefox popped up a "Redirect not configured correctly" error and said that it thought that the redirect would create a never ending loop.

I'm wondering how to set this up and any help would be appreciated. Thank you!

© Server Fault or respective owner

Related posts about domain

Related posts about nginx