I would like to understand what the proper Nginx configuration is to redirect everything to http://example.com/ ... Namely:
Need to redirect to http://example.com/ automatically. How do I configure that?
You can do something like this:
server {
listen 80;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
<your other nginx settings>
}
server {
listen 443;
server_name www.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
listen 443;
server_name example.com;
return 301 http://example.com$request_uri;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.