Could somebody share php code for geo-reditect script?

Here you go:
Code:
https://maxmind.github.io/GeoIP2-php/
 
pretty good guide here also:
https://github.com/maxmind/GeoIP2-php

Think it is just a case of uploading those files to your site and then using their php script which is ready to go.

It will work with the free databases provided by maxmind, or you can sign up for their realtime data service which is about $20 per 200,000 queries...
 
Use the search button, asked many times and answered many times!
 
Use the search button, asked many times and answered many times!

I already did searched whole Internet. Old geo-redirect scripts don't work anymore because maxmind changed something. If you are so smart then tell me one thread on BHW where could I find working script?
 
Last edited:
Here you go:
Code:
https://maxmind.github.io/GeoIP2-php/

Thx, but I do not know how to use composer. Why I need to download desktop application "composer" to code something when I actually need only redirect script on my server not on my PC. Also there is no geo-redirect script.

pretty good guide here also:
https://github.com/maxmind/GeoIP2-php

Think it is just a case of uploading those files to your site and then using their php script which is ready to go.

It will work with the free databases provided by maxmind, or you can sign up for their realtime data service which is about $20 per 200,000 queries...

I think this is the same as MrBlue shared. You say use their script, but that script is not even geo-redirect script. From the code I could see that it is detecting users IP location. There is no code for geo-redirect.
 
Thx, but I do not know how to use composer. Why I need to download desktop application "composer" to code something when I actually need only redirect script on my server not on my PC.

Composer is a dependency manager for PHP. It's not required that you use composer to download and use the script but it does make things easier.

...Also there is no geo-redirect script.
I think this is the same as MrBlue shared. You say use their script, but that script is not even geo-redirect script. From the code I could see that it is detecting users IP location. There is no code for geo-redirect.

There certainly is a sample GEO-IP script. Did you not see the "City Example" just below on the same page?
 
Composer is a dependency manager for PHP. It's not required that you use composer to download and use the script but it does make things easier.



There certainly is a sample GEO-IP script. Did you not see the "City Example" just below on the same page?

I just need simple country geo-redirect script. For example:

- First detect users country

- if user is from US redirect him to website 1
- if user is from CA redirect him to website 2
- if user come from rest of the world redirect him to website 3

That is simple redirect script I need. That "City Example" you gave me is detecting country, city, latitude, longitude etc. I just need simple country redirection script, but don't know how to do that.
 
Last edited:
Good morning SpecialOne

I already sent you a solution replying your PM.

Option 1 is easy to implement, but if you want the better option 2 and need help, contact me.

Have a nice day.

I just need simple country geo-redirect script. For example:

- First detect users country

- if user is from US redirect him to website 1
- if user is from CA redirect him to website 2
- if user come from rest of the world redirect him to website 3

That is simple redirect script I need. That "City Example" you gave me is detecting country, city, latitude, longitude etc. I just need simple country redirection script, but don't know how to do that.
 
If you go to my blog webdevtown . c0 m and search for 'location' you'll find exactly what you're after. It's a script I released a while ago that uses an API to detect country and redirect user.

If anything else, lemme know.
 
Back
Top