我需要将每个http://test.com请求重定向到http://www.test.com。如何才能做到这一点。
在服务器块中,我尝试添加
rewrite ^/(.*) http://www.test.com/$1 permanent;
但在浏览器中说
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for
this address in a way that will never complete.
我的服务器块看起来像
server {
listen 80;
server_name test.com;
client_max_body_size 10M;
client_body_buffer_size 128k;
root /home/test/test/public;
passenger_enabled on;
rails_env production;
#rewrite ^/(.*) http://www.test.com/$1 permanent;
#rewrite ^(.*)$ $scheme://www.test.com$1;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
官方文档位于:nginx.org/en/docs/http/converting_rewrite_rules.html
—
Marcello Nuccio