Wednesday, October 28, 2015

Redirect rules for nginx server block

If you want server_name without www then follow this
server {
 listen 80 default_server;
 server_name subdomain.domain.com;
 passenger_enabled on;
 passenger_app_env production;
 root /home/sachin/testapp/public;
}
server {
listen 80;
server_name www.subdomain.domain.com;
return 301 $scheme://subdomain.domain.com$request_uri;
}
If you want server_name with www then follow this
server {
 listen 80 default_server;
 server_name www.subdomain.domain.com;
 passenger_enabled on;
 passenger_app_env production;
 root /home/sachin/testapp/public;
}
server {
 listen 80;
 server_name www.subdomain.domain.com;
 return 301 $scheme://www.subdomain.domain.com$request_uri;
Ref. taken from here. 
Reactions:

0 comments:

Post a Comment