Forum Moderators: phranque
I want to block certain countries from visiting my site for this I have written a test.php page which test the ip of the user against a table and then take the decision whether to send the user to the site or back to the block message page...
I am using this htaccess code
Code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI}!^.*test\.php.*$
RewriteRule ^(.*)$ test.php?var1=$1 [L]
</IfModule>
means, if the URL is not domain.com/test.php send the user to test.php page for checking his ip otherwise he is already checked for his ip and keep him on the page he wants to.
now when test.php page sends user back to the exact URL he puts to visit the page ($var1) the user is again redirected because the htaccess rule again matches and my RewriteCond doesn't work...
How can I prevent it from looping so that if a user is already checked for his IP he should not be checked again?
any help is highly appreciated...
Remember that an external redirect ends the current HTTP transaction and tells the client (browser or robot) to start a new one. Because of this, and because HTTP is a 'stateless' protocol, Apache will have no 'memory' of previous requests, and cannot 'know' that a second request is related to a first request. Therefore, access control must be accomplished completely within the context of a single HTTP request, meaning you cannot use an external redirect. You can use internal URL rewriting, as available in mod_rewrite, or you can include scripts and content conditionally, but no external redirects.
Jim
my main problem is that currently all pages are .html and not .php so I can't include some snippet to check IP...
host doesn't have mod_geoip support otherwise it was piece of cake for me :)
however I do have complete geoIP binary file which has all the IPs in it and I can compare visitor's IP against it.
so what I have is geoIP db, all html pages, mod_rewrite enabled, htaccess working.. nothing beyond it..
what could be way out? I am stuck with it for the last five hours now :(
Jim