You are not logged in.
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!
I had the same issue (which I eventually gave up). Check out this post and Jukka’s answer
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?
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
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
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)
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….