0

I'm deploying a website with NGINX and Wordpress. To redirect from non-www to www, I put some code to NGINX config:

if ($host = example.com) {
    return 301 https://www.$host$request_uri;
}

I checked with Curl:

curl http://example.com
Result:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.14.0 (Ubuntu)
Date: Mon, 03 Jun 2019 16:19:28 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: https://www.example.com/

But browser address bar still shows: https://example.com/.

I have to change URL setting in Wordpress General from example.com to www.example.com, browser address bar will shows: https://www.example.com/ as what I expected.

So:

Why I have to redirect non-www to www in 2 places (in NGINX and Wordpress Setting)?

  • 1
    http != https – Alexey Ten Jun 3 at 17:19
  • Please check curl https://example.com/ as well. – András Korn Jun 3 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.