Forum Moderators: phranque

Message Too Old, No Replies

IP ban exemption

         

kanin

3:03 pm on Sep 27, 2009 (gmt 0)

10+ Year Member



A client would like to ban all IPs in the country so as to ban the competitors from viewing.

But he needs to exempt his own IP,
he is now using .htaccess "order allow,deny" command.

Does anyone know how to do so? thanks.

jdMorgan

3:13 pm on Sep 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If doing so will not affect other/existing access-control logic, reverse the Order to "Deny,Allow." Then add an "Allow from" for your client's IP address (and your own).

If you are serious about "banning countries," then you will need to use a service such as GeoIP to find all of the current IP address ranges for those countries. IP addresses *are not* assigned on a country-by-country basis, and they change constantly. Therefore, in order to keep up with current address-range-to-country relationships, you will either need to use a 3rd-party service or hire a staff to track the daily changes.

Be aware that banning a single country without banning any others may require several hundred "Deny from" entries in your list, and will require constant monitoring for changes.

Jim

kanin

3:27 pm on Sep 27, 2009 (gmt 0)

10+ Year Member



thanks Jim!

so it will be like this?

order deny,allow
deny from (ban ip 1)
deny from (ban ip 2)
deny from (ban ip 3)
deny from (and so on)
allow from all
allow from (client's ip)
allow from (own ip)

jdMorgan

3:52 pm on Sep 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It does not matter what order you put the "Allow from" and "Deny from" lines; They are always processed in the order specified by the "Order" directive.

In case it is not clear, the "Order" directive sets the priority of "Allow" and "Deny." "Order Deny,Allow" means that "Denies" are processed first, but can be overridden by "Allows," whereas "Order Allow,Deny" means that "Allows" are processed first but can be overridden by "Denys." This is true without regard to the order of the individual "Allow" and "Deny" directives in your file; the order that you list them in does not matter at all.

Do not use "Allow from All" with "Order Deny,Allow" because that would mean that all "Denys" will be overridden by that "Allow."

Jim

wilderness

3:54 pm on Sep 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No. [with "Order Allow,Deny"], the denies are not necessary because EVERYBODY is denied by default.

order deny,allow
allow from (client's ip)
allow from (own ip)
deny from all

[edited by: jdMorgan at 9:48 pm (utc) on Sep. 27, 2009]
[edit reason] Edited for specificity. [/edit]