So, I'm setting up a new potentially high traffic site that's made up of several simple static pages. We want to host it as efficiently as possible, as we're both on a non-existent budget and may have to deal with traffic spikes, so have been thinking CloudFlare, AWS S3/CloudFront, or some similar service.

However, the catch is we need the root page / to redirect to /ccTLD, for example: redirect to /us for U.S. visitors or /au for Australian visitors.

Does anyone have any ideas on how we can best approach this? So far I'm thinking either we have to resort to using JavaScript which looks dodgy, or simply pushing / requests through to a VPS or EC2 instance, which creates a bottleneck I'd rather avoid.

2 Answers 2


The simplest and cheapest option of course would be to just let visitors direct themselves as many large corporate sites do, however this may not be ideal for your site...

So if you don't want to use JavaScript, like Maxmind's Free GeoIP2 JavaScript API, then using a combination of the PHP GeoIP Location extension with Maxmind's Free GeoIP Country database and Amazon's Elastic Compute Cloud (EC2) might be the most efficient and economical way to go taking into consideration scaling and start-up factors.


CloudFlare has an awesome feature that automatically injects the user's country into the request headers (and this works even on their free plan). You could then easily use a server side redirect to direct the visitor to the appropriate URL based on this header.

I've been running CloudFlare on top of our site for a while and am loving it so far.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.