First time user redirect based on geographic location

There are two versions of the website in my project - American and International. This is not localization, the language is the same, only content changes. I created a subdomain for the American version and saved the international version in the main domain.

Now I googled for the solution to redirect US users to the US default website and used the Geo redirect plugin ( http://wordpress.org/extend/plugins/geographical-redirect/ ).

Now the problem is, this plugin redirects visitors from the US every time they try to open the international version. I have to do this, the user must be redirected to the American version on the first visit, and then through the referrer link that I posted on the US website, the visitor should be allowed to visit the international version and view the website. But then again, if a user tries to open a site directly, he should be redirected to a version in the USA.

How to do it?

+4
source share
1 answer

You can do this using a cookie.

The first time you log in to the USA, you will set a cookie

Then you execute and check the IF on each page to see if the specified cookie (or a specific value) is set

If the cookie does not exist, they are redirected to the US website, if it exists, than you are redirected to any other link.

+1
source

All Articles