Direct web country traffic - how to.

by Shift
2 replies
Hello.

I want to direct all traffic from a specific country to an opt-in page.

I read about a .htaccess file one can create to block an IP so maybe my answer lies in .htaccess?

---
order allow,deny
deny from 000.00.0.0
allow from all
---

Someone else also mentioned this :

Search the IP range that you want to redirect, than make an htacess file with the following syntax:
RewriteCond %{REMOTE_ADDR} ^64\.126\.81\.30$ [OR]
RewriteCond %{REMOTE_ADDR} ^75\.117\.244\.27$
RewriteRule .* http://www.mysite.com/europe.htm [R,L]
(edit the ranges and the site/page and do not add the [OR] on the last line of IPs)

---

Now I can go here and get all the IP addresses for a country (there's quite a few) IP Range - Ip Address Range Lookup - Ip Range Finder but I'm not sure how to implement this in an .htaccess file.
Must I include this in the htaccess file - deny from xxx - and then list all the IPs that the url I just mentioned shows.

Please help, thanks a lot.
#country #direct #traffic #web
  • Profile picture of the author Shift
    I don't mean to sound impatient but if anyone knows the exact solution for this please comment.

    I can go here and get all the IP addresses for a country (there's quite a few - 485) http://www.ipaddresslocation.org/ip_...get_ranges.php
    but I'm not sure how to implement this in an .htaccess file.

    It also lists them like this for example 41.0.0.0 41.31.255.255 (which I assume is a range).

    Must I list every IP that the ipaddresslocation I just mentioned shows?

    Or must it be in a different format like -

    <Files *>
    order deny,allow
    deny from 000.00.0.0
    allow from all
    </Files>

    Thanks.
    {{ DiscussionBoard.errors[1421687].message }}
    • Profile picture of the author mojojuju
      Well, I think an easier way to go about doing this is to use the GeoIP tools from MaxMind. In particular, the mod_geoip for Apache. An introduction can be found here MaxMind - GeoIP Apache API
      Signature

      :)

      {{ DiscussionBoard.errors[1421982].message }}

Trending Topics