Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have 2 sites running on nginx (php wordpress).

For some reason redirects are working differently, although they both have the same vhost setup.

domain1.com redirects to www.domain1.com
www.domain1.com stays at www.domain1.com

domain2 seems to be acting strainge:

domain2.com stays at domain2.com
www.domain2.com redirects to domain2.com

What could be the issue?

both vhosts have this:

server_name domain1.com www.domain1.com
server_name domain2.com www.domain2.com

What I want is for both domains to redirect from domain.com to www.domain.com

share|improve this question
Will need your configuration file to tell, right now you're asking people to make random guesses. –  Martin Fjordvald Jun 26 '10 at 2:12
We'll also need to know what code (if any) you've got running within those sites, as code can also generate redirects. –  BMDan Jun 26 '10 at 3:54
Also post the output of wget --spider -qS http://{,www.}domain{1,2}.com/. –  joschi Jun 26 '10 at 8:17

1 Answer 1

I suspect it's most likely that wordpress is configured differently and is handling the rewrites in one case.

You can configure nginx to always redirect with something like:

if ($host ~* ^domain\.com) {
     rewrite ^(.*)$ http://www.domain.com$1 permanent;
share|improve this answer
it was wordpress after all, thanks a million! –  Blankman Jul 1 '10 at 18:59

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.