.htaccess Redirect with Cloudflare location
<p>I'm really struggling to place redirects into my .htaccess file based on the cloud flare country code. I'm either getting "too many redirect errors" or 500 internal errors using examples from across this site.</p>

<p>I currently have this:</p>

<pre><code>Options +FollowSymLinks
RewriteEngine on

SetEnvIf CF-IPCountry "(.*)$" Country=$1

RewriteCond %{ENV:Country} GB
RewriteRule ^(.*)$ http://example.com/$1 [R,L]
</code></pre>

<p>So I need the default domain to be <a href="http://example.com" rel="nofollow">http://example.com</a></p>

<p>but if a country code of GB comes from cloudflare for example, I need it to redirect to:</p>

<p><a href="http://example.com/gb" rel="nofollow">http://example.com/gb</a></p>

<p>With my limited knowledge of .htaccess is this possible?</p>