Correct Rewrite?

mevans336 nginx-forum at
Fri Mar 11 20:12:26 UTC 2016

We currently use the following method to perform an http to https rewrite.

rewrite ^ https://$server_name$request_uri permanent;

I am planning to change it to the preferred method of:

return 301 https://$server_name$request_uri;

However, we'd like to also make sure any requests for are sent to, whether someone tries to access via http or

How would I write the redirect statement to rewrite http:// to https:// but
also rewrite to

Posted at Nginx Forum:,265257,265257#msg-265257

More information about the nginx mailing list