我想使用以下重定向配置Nginx(puma + rails 4)应用程序:
http://example.com ----> http://www.example.com (using 301 redirection)
除非uri是/ api / *
http://example.com/api/someapi (no redirection).
我尝试使用301返回的推荐附加服务器块,但我无法弄清楚如何正确执行。
server {
listen 80;
server_name example.com;
location /api/ {
?? I would like to avoid copying the whole www.example.com server directives here.
}
location / {
return 301 http://www.example.com$request_uri;
}
}
server{
listen 80;
server_name www.example.com
#
# many directives follow...
#
}
我想:
任何提示?非常感谢 ! 阿诺