Skip to content

Commit 2246ca3

Browse files
committed
Update force_non_www.conf
1 parent ae91310 commit 2246ca3

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Redirect www.example.com to example.com
22

3-
if ($host ~* ^www\.(.+)$) {
4-
return 301 $scheme://$1$request_uri;
3+
if ($http_host ~* '^www\.(.+)$') {
4+
if ($http_x_forwarded_proto ~* '^https$') {
5+
return 301 https://$1$request_uri;
6+
}
57
}
8+
9+
if ($http_host ~* '^www\.(.+)$') {
10+
if ($scheme = "https") {
11+
if ($http_x_forwarded_proto = "") {
12+
return 301 https://$1$request_uri;
13+
}
14+
}
15+
}
16+
17+
if ($http_host ~* '^www\.(.+)$') {
18+
if ($scheme != "https") {
19+
if ($http_x_forwarded_proto !~* '^https$') {
20+
return 301 http://$1$request_uri;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)