title: Nginx redirect to www domain not working
body: <p>I have the following nginx configuration.</p>
  
  <pre><code>server {
      listen 80;
      listen [::]:80;
      listen 443 ssl;
      server_name example.com;
      return 301 https://www.example.com$request_uri;
  }
  </code></pre>
  
  <ul>
  <li>it redirects <code>http://example.com</code> to <code>https://www.example.com</code></li>
  <li>but does not redirect <code>https://example.com</code> to <code>https://www.example.com</code>.</li>
  </ul>
  
  <p>How can I redirect <code>https://example.com</code> to <code>https://www.example.com</code>?</p>