-2

I am new to Nginx and looking out for a configuration to prepend 'www.' to my rails application url.

For example, if a user submits example.com into the browser url section the nginx should rewrite the url as www.example.com and redirect.

Kindly help me achieve this.

Edit

The linked question's answers doesn't serve my requirement since the approach suggested is related to Apache and redirection is performed through ApplicationController. I request the StackOverflow Community members to interfere, remove the negative reputation points and grant me the required permission to ask more questions.

1 Answers1

0

For Nginx

server{
 listin 80;
 server_name xyz.com;
 rewrite ^(.*)$ $scheme://www.xyz.com$1;
}
Gupta
  • 8,882
  • 4
  • 49
  • 59