|
楼主 |
发表于 2020-7-3 22:38:35
|
显示全部楼层
河小马 发表于 2020-7-3 21:23
* U) V$ Z. O: F# C* i# w8 _8 S5 Ishopify 可以前面挂cf吗?
/ X' u- j5 M; m% y3 \! P! |
: Q% v3 C/ {, K; P/ ]; ^ @cf 实现这个很容易
8 [$ U/ ~) p! c7 H" G7 l N& M- e! N# S应该不行,只能用DNS Only模式,然后shopify会generate一个let's encrypt,我看几个top shopify店铺都是这样的+ }( \* Q* A" M% |3 E8 C5 E/ e
. G( ^; B' \! r$ R9 C( X
自己写code感觉就很麻烦了。。。 J8 Q3 `/ ?: i6 a8 G3 J
/ P. J6 Y2 N, @& X" M在shopify的社区找到了这个代码,不过这个freegeoip.app感觉不稳3 r H: C& e& Q) ~
- l! W( B& o4 y, m4 i+ U
- // IpGeolocation$ U5 y3 q; k( X$ [3 v9 A1 A
- var httpRequest = new XMLHttpRequest();
3 K" |6 L0 m0 o" U - ' V( w! n! h& q( R2 y/ \% w
- httpRequest.onreadystatechange = function() {1 h$ i! \6 ~3 k" A* _" X: ~
- if (4 === this.readyState && 200 === this.status) {. H: |' C" \( [+ ]8 H# m" a
- var json = JSON.parse(this.responseText);0 j9 O7 H! ?% v; y9 C
- redirect(json.country_code);
+ N. d* O/ S8 Y. H+ U1 P, [ - }
5 p5 w2 C1 } [% b - }2 k) a6 l. c' W0 h+ N9 Q7 s3 V3 a9 U
- httpRequest.open("GET", "https://freegeoip.app/json/", false);
; C# G6 v0 V5 ?) v3 N - httpRequest.setRequestHeader("Accept", "application/json");
6 q; ?( k r; ?- k - httpRequest.send();" G- j" d7 z1 i
- " H( O0 l7 ]% @ v4 g# c n
- function redirect(country_code) {
0 `; W' A' k. `, j
2 M) Q, B1 N! M8 z2 n- if (country_code == "CN" ) {
$ H& s1 R1 J, k3 p+ r" a$ F. v
- Z" c$ v8 ^5 a- window.location.href = "https://www.nasa.gov/";
p& q! Y# l8 n. Q6 g1 d' T6 f - }1 A$ j4 g% ?5 i2 r7 I
0 N- e3 @) U3 ]) k; E( s7 I# M0 \- else if0 m; @# j% Z: [: g
- (country_code == "MO" ) {
/ U( t: L' q# ^; u7 @2 X! g - window.location.href = "https://www.nasa.gov/";9 F1 N8 |" [ }
- }2 ]: M: L0 {0 | Q8 A" ?
- 7 Z! ?5 K* N3 f! d7 v/ Z- G6 V" a1 g+ F& r
2 @" V) N* v5 A9 q/ @- else if9 c5 _; Y+ k O5 `3 g4 c! ~% n
- (country_code == "SG" ) {
K7 w {7 d, x6 r) {/ H - ! L9 v' L- N% D- Q) T+ G
- window.location.href = "https://www.nasa.gov/";, d+ h7 ^! M; S# \# B+ Z" x
- }
1 R/ g+ K, i. S- U - , D4 E; N) }& _
- else if
( n/ K* X+ n. j; n8 L7 C - (country_code == "EE" ) {$ ?! P) w& v( Z1 _, s% {
. k+ o0 B4 _* v7 n2 E' S- window.location.href = "https://www.nasa.gov/";
1 t0 i2 x: r, v; Q2 O( x - }' T! z8 h$ K: g* |; w/ S
- : Q* f/ E) V1 D1 o5 ^
6 d# p1 B; k; W- else {
4 J1 P& a$ x5 U; a/ {( R - return9 j8 M0 `) [& u9 R8 g; \
- }' h) B& U# H9 s5 k/ f9 K `- _
- }
复制代码 |
|