Redirect users according to their geo location

I want to create a rule where if a user is from India he will be redirected to /en-in otherwise no redirection. How to do that, i want to avoid php so is there any other idea ??

Also avoid Javascript? if yes you cannot.

can htaccess work ?

No, you must use javascript or php at least.

<script language="Javascript" src=",GeobytesCode,GeobytesInternet"></script>
<script language="Javascript">
   // Something has gone wrong with the variables, so set them to some default value,
   // maybe set a error flag to check for later on.
   var sGeobytesLocationCode="unknown";
   var sGeobytesCode="unknown";
   var sGeobytesInternet="unknown";
   // Visitors from India would go here"enter Indian URL here");
}else if(sGeobytesCode=="IN")


just adding this will work ??

there is one way to make it work using .htaccess only if you are using cloudflare.
First from network tab in cloudflare enable IP Geolocation
Then add this code in your site .htaccess

SetEnvIf CF-IPCountry “(.*)$” Country=$1
RewriteCond %{ENV:Country} IN
RewriteRule ^(.*)$$1 [R,L]



I want to redirect indian visitors from to will be same for everyone. Where should i include in htacess ??

Best would be making sub domains and using the Javascript method given by @anon19508339

Yeah using cloudflare.

SetEnvIf CF-IPCountry “(.*)$” Country=$1
RewriteCond %{ENV:Country} IN
RewriteRule ^plans/(.*)$ /inplans [R,L]

Replace plans with one you want to redirect from and replace inplans with where you want to redirect to.

Reference: Redirect One Directory To Another With .htaccess | #! code

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.