I need to forward all visitors from "domain.com" to "www.domain.com".

I know this has something to do with altering the nginx config file but am not sure what to do or what code to use.

I am using nginx as the server.

Any help would be appreciated :)

link|improve this question
1  
Just do opposite: serverfault.com/questions/35955/… – quanta Aug 2 '11 at 14:15
feedback

3 Answers

In my own NGINX setup, I made a separate vhost for domain.com:

server {
  listen   1.2.3.4:80;
  server_name  domain.com;
  rewrite  ^(.*) http://www.domain.com$1 permanent;
}
link|improve this answer
Thanks Sgaduuw your solution have helped and it works :) – Jayesh Gopalan Aug 4 '11 at 7:41
feedback

Apparently I can't just have a link as an answer...

Anyway, check out this question: Nginx: Forward all Subdomains

The config there should work for you.

link|improve this answer
feedback

You can rewrite the URL in the config file like this:

server {
    server_name  domain.com;
    rewrite ^(.*) http://www.domain.com$1 permanent;
}

server {
    server_name  www.domain.com;
    #My other config options
}
link|improve this answer
Thanks TiZon for your solution and it works and it helped me once again Thanks :) – Jayesh Gopalan Aug 4 '11 at 7:42
@Jayesh Gopalan Could you mark the question as solved then? That wey it won't pop up on the main page as an unsolved question. – Bart De Vos Aug 4 '11 at 8:01
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.