[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Forwarding to a web page based on ip address

Posted on 2011-10-06
5
Medium Priority
?
263 Views
Last Modified: 2012-08-13
Hi all

I have tasked with finding out the following

We are a sales company and also act as a reseller for other companys, what that would like to is if someone is buying a product from one of our resellers website what would happen at the moment is they would click on what they want to buy and then go to a third party shopping cart site, what I would like to know is, is it possible if anyone wants to buy a product and that user is based in the uk can the website detect this and if so could they then be redirected. To another site with different prices, if they are not in the uk it would just work as normal.

I must add I know nothing about the website that I am talking about ie: what it's written in etc, I just would like to know if it's possible and what steps I would need to advise on to achieve this.

Thanks

John
0
Comment
Question by:pepps11976
5 Comments
 
LVL 3

Expert Comment

by:ganix
ID: 36927083
You can detect country and language with javascript. Here are two links that could be usefull for you to check:
http://javascript.about.com/library/bllang.htm
http://www.javascriptkit.com/jsref/navigator.shtml
0
 
LVL 12

Expert Comment

by:ErezMor
ID: 36927085
as i only work with asp.net, i often use Page.Request.UserHostAddress() to get the ip address of the user calling the page.
having that at hand, there are many web-sites/web services that given an ip adddress will tell you not only from which country the request originated, but from which town/region
0
 

Author Comment

by:pepps11976
ID: 36927097
Thanks for the info so if I used one of the above methods to check the origin of the user how do you code to say if from united kingdom then go to different site?

John
0
 
LVL 9

Accepted Solution

by:
jan-janssen earned 1000 total points
ID: 36927170
A friend of mine wrote a script for this http://shockmarketer.com/geoip-country-location-php-script/ the script http://shockmarketer.com/country-redirect/country-redirect.php.zip simply gives you the country code then you can simply modify the code country-redirect.php in 503, simply replace
echo $country;

Open in new window

with
if($country == 'UK')
{
header('Location: http://example.co.uk');
exit();
}
else if($country == 'US')
{
header('Location: http://example.com');
exit();
}

Open in new window


For the script to work it also required the IP Map to be placed in the same directory
http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
0
 
LVL 3

Assisted Solution

by:ganix
ganix earned 1000 total points
ID: 36927225
I've remember I saved some bookmarks with this kind of request. Here you have the entire code in php from Harald Hope under GNU public license:
http://techpatterns.com/downloads/scripts/php_language_detection.txt

Hope this was helpfull.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
What You Need to Know when Searching for a Webhost Provider
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question