Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-18-2012, 09:10 PM   PM User | #1
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Different landing page for different geo location

As far as I know there are 2 ways to do it. One is the .htaccess and one by using php.

What I'm looking for is let say if my visitor is from US the it will go to the default

mywebsite.com

if from UK
mywebsite.com/uk

from Bangladesh
mywebsite.com/bd

and so on. If i don't have specific code for certain countries traffic from those countries will just go to he default page.

Thanks in advance.
ameerulislam is offline   Reply With Quote
Old 08-18-2012, 10:53 PM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,155
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
http://www.livio.net/main/charset.asp

That site may provide some useful info, especially the HTTP_ACCEPT_LANGUAGE

It can also be done with an IP list by country. There doesn't seem to be a 100% assured way, or an easy way.
DrDOS is online now   Reply With Quote
Old 08-18-2012, 11:09 PM   PM User | #3
ECoode
New Coder

 
Join Date: Aug 2012
Location: Finland
Posts: 23
Thanks: 2
Thanked 5 Times in 5 Posts
ECoode is an unknown quantity at this point
PHP Code:
$Language substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2); 

if( 
$Language == "fi" ){ //fi for Finland (My language..)
    
echo "You're from Finland!";
}else{
    echo 
"This is finnish site, you should use translator!";

This might get you started ^^!
ECoode is offline   Reply With Quote
Old 08-19-2012, 04:20 AM   PM User | #4
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Quote:
Originally Posted by ECoode View Post
PHP Code:
$Language substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2); 

if( 
$Language == "fi" ){ //fi for Finland (My language..)
    
echo "You're from Finland!";
}else{
    echo 
"This is finnish site, you should use translator!";

This might get you started ^^!
I actually need it to redirect to the appropriate landing page.


Let say if it is Finland it will go

mysite.com/fn , even if I had typed mysite.com to enter my site.

Last edited by ameerulislam; 08-19-2012 at 04:23 AM..
ameerulislam is offline   Reply With Quote
Old 08-19-2012, 06:36 AM   PM User | #5
sonny
Regular Coder

 
sonny's Avatar
 
Join Date: Apr 2008
Location: United States
Posts: 567
Thanks: 88
Thanked 0 Times in 0 Posts
sonny can only hope to improve
You can do this with the GeoIP max mind database
if you go that route, I will show you how easy
that is to do. I would do that now, but I can't keep
my eyes open.

Sonny
sonny is offline   Reply With Quote
Old 08-19-2012, 06:49 AM   PM User | #6
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Quote:
Originally Posted by sonny View Post
You can do this with the GeoIP max mind database
if you go that route, I will show you how easy
that is to do. I would do that now, but I can't keep
my eyes open.

Sonny
Ok bro, reply me when you wake up.

Good night and Thanks!
ameerulislam is offline   Reply With Quote
Old 08-19-2012, 06:51 AM   PM User | #7
Len Whistler
Senior Coder

 
Len Whistler's Avatar
 
Join Date: Jul 2002
Location: Vancouver, BC Canada
Posts: 1,323
Thanks: 26
Thanked 100 Times in 100 Posts
Len Whistler is on a distinguished road
Quote:
Originally Posted by ameerulislam View Post
I actually need it to redirect to the appropriate landing page.


Let say if it is Finland it will go

mysite.com/fn , even if I had typed mysite.com to enter my site.


Study if statements like the one ECoode provided and use this:

PHP Code:
header('Location: http://www.mysite.com/fn'); 


----
__________________
Leonard Whistler
Len Whistler is offline   Reply With Quote
Old 08-19-2012, 06:54 AM   PM User | #8
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Quote:
Originally Posted by Len Whistler View Post
Study if statements like the one ECoode provided and use this:

PHP Code:
header('Location: http://www.mysite.com/fn'); 


----
Hei Len, I figured out that part, but I don't know where to get the ip database or function to do the comparison.

I'm retrieving ip $_SERVER['REMOTE_ADDR'];

now I want to say if ip is in certain range go redirect to certain page.

Is there anything built in php that has ip range database or something?
ameerulislam is offline   Reply With Quote
Old 08-19-2012, 06:58 AM   PM User | #9
Len Whistler
Senior Coder

 
Len Whistler's Avatar
 
Join Date: Jul 2002
Location: Vancouver, BC Canada
Posts: 1,323
Thanks: 26
Thanked 100 Times in 100 Posts
Len Whistler is on a distinguished road
Quote:
Originally Posted by ameerulislam View Post
Is there anything built in php that has ip range database or something?
No .... As far as I know you would have to buy the ip database and pay some sort of subscription to keep it up to date.





----
__________________
Leonard Whistler
Len Whistler is offline   Reply With Quote
Old 08-19-2012, 06:58 AM   PM User | #10
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Quote:
Originally Posted by Len Whistler View Post
Study if statements like the one ECoode provided and use this:

PHP Code:
header('Location: http://www.mysite.com/fn'); 


----
what's ECoode, I looked up and can't find any definition of it.
ameerulislam is offline   Reply With Quote
Old 08-19-2012, 07:00 AM   PM User | #11
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Quote:
Originally Posted by Len Whistler View Post
No .... As far as I know you would have to buy the ip database and pay some sort of subscription to keep it up to date.





----
Is it so? There should be a free alternative or maybe a list that is big enough that I wouldn't need to worry about some minor updates.
ameerulislam is offline   Reply With Quote
Old 08-19-2012, 07:02 AM   PM User | #12
Len Whistler
Senior Coder

 
Len Whistler's Avatar
 
Join Date: Jul 2002
Location: Vancouver, BC Canada
Posts: 1,323
Thanks: 26
Thanked 100 Times in 100 Posts
Len Whistler is on a distinguished road
Quote:
Originally Posted by ameerulislam View Post
what's ECoode, I looked up and can't find any definition of it.

Post #3.

Quote:
Originally Posted by ameerulislam View Post
Is it so? There should be a free alternative or maybe a list that is big enough that I wouldn't need to worry about some minor updates.

I figure there might be some limited free ip database. You would have to Google it and see if you can find one.


---




----
__________________
Leonard Whistler
Len Whistler is offline   Reply With Quote
Old 08-19-2012, 07:06 AM   PM User | #13
ameerulislam
New to the CF scene

 
Join Date: Aug 2012
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
ameerulislam is an unknown quantity at this point
Quote:
Originally Posted by Len Whistler View Post
Post #3.




I figure there might be some limited free ip database. You would have to Google it and see if you can find one.


---




----
oooh Poster Ecoode lol
ameerulislam is offline   Reply With Quote
Old 08-19-2012, 01:45 PM   PM User | #14
Will Bontrager
Regular Coder

 
Join Date: Jun 2012
Location: Near Chicago, USA
Posts: 123
Thanks: 7
Thanked 19 Times in 19 Posts
Will Bontrager is an unknown quantity at this point
Quote:
Originally Posted by ameerulislam View Post
Is it so? There should be a free alternative or maybe a list that is big enough that I wouldn't need to worry about some minor updates.
See the "Free / Open Source" column at
http://www.maxmind.com/app/ip-location

Will
__________________
Numerology API for apps - Facebook, iPad, mobile phones. No charge to use API. [info]
Will Bontrager is offline   Reply With Quote
Users who have thanked Will Bontrager for this post:
ameerulislam (08-20-2012)
Old 08-24-2012, 10:14 AM   PM User | #15
chrislim2888
New to the CF scene

 
Join Date: Mar 2012
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
chrislim2888 is an unknown quantity at this point
Instead of keeping your own database, you can choose using the free web service http://www.ipinfodb.com
chrislim2888 is offline   Reply With Quote
Users who have thanked chrislim2888 for this post:
ameerulislam (08-24-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:10 PM.


Advertisement
Log in to turn off these ads.