Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-07-18 13:55:50
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Geolocation - IP redirect geo-targeting for corporate customers
hi all,
I was wondering, what would be the best way to go about doing a country/IP geolocation redirect in TXP.
I’ve done little bits of in page PHP to change some content based on IP location etc….but now I’ve got two corporate sites that I want say, visitors from Canada on our US site to be sent over to the CA one.
The service to do the geolocation is generally php based etc, so it’s not something that would be on the server-side .htaccess or anything.
But I’m talking about a redirect in the core of TXP’s load process….
just thinking off top of my head, one other way to do it would be the old meta refresh way, and put that in the main TXP Page code…..
anyone had any experience implementing a solution for this?
thanks for any suggestions!
Offline
Re: Geolocation - IP redirect geo-targeting for corporate customers
Hi Chris
I had the same issue (which I eventually gave up). Check out this post and Jukka’s answer
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#3 2012-07-18 17:37:39
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: Geolocation - IP redirect geo-targeting for corporate customers
thanks colak,
yeah, I know about the geoip database method, I am doing that successfully already for certain pages where I wanted some region-specific content display. Works well using simple txp:php tags and a couple lines of php to query and parse the geolocation api.
The question is now, how can I expand that out to redirect a whole site, and what is the best method to do the actual redirecting — some sort of header plugin or a meta refresh?
Offline
#4 2012-07-20 16:12:52
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: Geolocation - IP redirect geo-targeting for corporate customers
so no suggestions about what method to do this? a plugin that controls header output might work, send a 302 or something
or the meta refresh method
—
Offline
Offline
#6 2012-07-23 15:30:39
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: Geolocation - IP redirect geo-targeting for corporate customers
no, not a html content header change, like the actual PHP header that’s being sent from the TXP core on every page load. How else could you initiate a 302
Offline
Re: Geolocation - IP redirect geo-targeting for corporate customers
What is wrong with <txp:mg_setheader name="Location" value="http://site.ca" />
, or even raw <txp:php>header("Location: http://site.ca"); exit();</txp:php>
?
Last edited by etc (2012-07-23 16:34:26)
Offline
#8 2012-07-23 17:11:55
- ChrisArchitect
- Member
- From: Canada
- Registered: 2007-06-20
- Posts: 25
Re: Geolocation - IP redirect geo-targeting for corporate customers
oh wow, sorry, I didn’t see clearly what mg_setheader was doing/capable of.
I guess that would work sort of
I am trying something a bit more advanced to get the 302 issued — editing or adding to http://textpattern.org.ua/plugins/aks_header
I just wrote a similar function to aks_301 that issues a 302 Found instead.
I realize that aks plugin is based on mg_setheader — so maybe just another level of functionality….
the next big question will be how good of a redirect to do I do for the visitors. inside page -> home page? or try and figure out what page they requested and send to equivalent page on other domain….
Offline