Kairike Posted November 15, 2023 Posted November 15, 2023 Hello, Is it possible to redirect Squarespace pages with the following code? I can't seem to get it to work. I have tried entering the code in the page header section. I'm trying to redirect to a language specific page within the same site, not a separate site/domain. Thank you! K. <script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script> <script> if(geoplugin_countryCode() != 'EE'){ if(geoplugin_countryCode() == 'GB'){ location.href = "https://www.wizardscreeklabradors.com/en/home/"; }else{ location.href = "https://www.wizardscreeklabradors.com/en/home/"; } } </script> Beyondspace 1
Solution Beyondspace Posted November 15, 2023 Solution Posted November 15, 2023 1 hour ago, Kairike said: Hello, Is it possible to redirect Squarespace pages with the following code? I can't seem to get it to work. I have tried entering the code in the page header section. I'm trying to redirect to a language specific page within the same site, not a separate site/domain. Thank you! K. <script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script> <script> if(geoplugin_countryCode() != 'EE'){ if(geoplugin_countryCode() == 'GB'){ location.href = "https://www.wizardscreeklabradors.com/en/home/"; }else{ location.href = "https://www.wizardscreeklabradors.com/en/home/"; } } </script> The problem is the script is called using HTTP protocol, while your Squarespace page is served as HTTPS, you will see this error in console indicated that browser not allow mixed-content, therefore the geoplugin_countryCode method is not usable To use the HTTPS protocol you need to buy SSL key subscription from them at 24 EUR per year https://www.geoplugin.com/premium Kairike 1 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </> 🗓️ Delivery Date Picker (Date picker form field) Gallery block 7.1 workaround </> 🤖 Ask me anything
Kairike Posted November 15, 2023 Author Posted November 15, 2023 6 hours ago, Beyondspace said: The problem is the script is called using HTTP protocol, while your Squarespace page is served as HTTPS, you will see this error in console indicated that browser not allow mixed-content, therefore the geoplugin_countryCode method is not usable To use the HTTPS protocol you need to buy SSL key subscription from them at 24 EUR per year https://www.geoplugin.com/premium Ah, great, thank you! I wouldn't have figured it out myself. Maybe that is why the example I found to write my code writes the location.href without HTTP or HTTPS (see below) but I tried that too, didn't work for me. 24€ a year is not too bad if that would guarantee that it works. Alternatives like Geo Targetly are way more expensive. <script> if(geoplugin_countryCode() != 'US'){ if(geoplugin_countryCode() == 'CA'){ location.href = "//www.domain.ca"; }else{ location.href = "//www.domain.com"; } } </script> Beyondspace 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment