Correct Rewrite?
Richard Stanway
r1ch+nginx at teamliquid.net
Fri Mar 11 20:29:24 UTC 2016
The way I do this is to use multiple server {} blocks, and put all the
non-canonical hostnames / port 80 requests in a server block with a return
301 to the canonical (and HTTPS) host which only listens on 443 and the
canonical hostname.
On Fri, Mar 11, 2016 at 9:12 PM, mevans336 <nginx-forum at forum.nginx.org>
wrote:
> 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 domain.com are sent
> to
> www.domain.com, whether someone tries to access domain.com via http or
> https.
>
> How would I write the redirect statement to rewrite http:// to https://
> but
> also rewrite domain.com to www.domain.com?
>
> Posted at Nginx Forum:
> https://forum.nginx.org/read.php?2,265257,265257#msg-265257
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160311/70911389/attachment.html>
More information about the nginx
mailing list