redirect related questions...

ST smntov at gmail.com
Fri Jul 28 11:13:23 UTC 2017


Hello,

I have several questions related to redirects:

Here is my setup:

server {
 server_name www.example.org example.com; # and some more domains
 return 301 $scheme://example.org$request_uri;
}

server {
 listen 80;
 server_name example.org;
 ...
 if ($http_user_agent !~ facebookexternalhit/1.1) {
  return 301 https://$host$request_uri;
 }
}

server {
 listen 443 ssl;
 server_name example.org;
 ...
}

1. http://example.com redirects correctly to https://example.org (via
http://example.org), but not https://example.com - why?

2. neither http://www.example.org nor https://www.example.org redirect
to https://example.org (not even to http://example.org) - why?

How can I achieve that?

Thank you in advance!



More information about the nginx mailing list