Created
July 18, 2020 05:31
-
-
Save miladoll/a2f1631cde965766e05a1bac0dfc36f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nginx で | |
# www.hogehoge.com -> hogehoge.com | |
# http://{www.}hogehoge.com -> https://hogehoge.com | |
# に一気に正規化する設定の例 | |
# server コンテキスト | |
set $redirect_canon_url ""; | |
set $canon_host $host; | |
if ( $host ~ ^www\.(.*)$ ) { | |
set $canon_host $1; | |
} | |
if ( $scheme = "http" ) { | |
set $redirect_canon_url "canon"; | |
} | |
if ( $host ~ ^www\. ) { | |
set $redirect_canon_url "canon"; | |
} | |
if ( $redirect_canon_url = "canon" ) { | |
return 301 https://$canon_host$request_uri; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment