Tôi cần chuyển hướng mọi yêu cầu http://test.com tới http://www.test.com. Điều này có thể giải quyết như thế nào.Cách chuyển hướng url trong NGINX
Trong khối máy chủ tôi đã cố gắng thêm
rewrite ^/(.*) http://www.test.com/$1 permanent;
nhưng trong trình duyệt nó nói
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.
khối máy chủ của tôi trông giống như
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;
}
}
Tài liệu chính thức có tại: http://nginx.org/en/docs/http/converting_rewrite_rules.html –