How do I block IPs using htaccess - .htaccess

How can I stop these IP addresses from hitting my site (185...* and 93.127..).
I have tried these in .htaccess:
Order Allow,Deny
Deny from 185.162.0.0/15
Deny from 185.164.0.0/14
Deny from 185.168.0.0/13
Deny from 185.176.0.0/12
Deny from 185.192.0.0/11
Deny from 93.127.0.0/16
Allow from all
and bots from http://tab-studio.com/en/blocking-robots-on-your-page/ but I continue to be hit.

Good: Edit (or create) the .htaccess file in the root of your server and put the following code:
order allow, deny
deny from 210.140.98.160
deny from 69.197.132.70
deny from 74.14.13.236
allow from all

Related

Allow certain IP ranges and googlebot, deny the rest, for certain URLs only

I need to modify and combine some .htaccess rules, in order to meet 3 separate conditions:
Allow access from certain IP ranges, deny the rest
Allow googlebot, no matter what IP
All this applies only to any URL containing 'theword'
<Directory "containing *theword*">
Order allow,deny
Deny from all
Allow from 192.168.0.2
Allow from 10.0.0.1
</Directory>
<Files "containing *theword*">
Order allow,deny
Deny from all
Allow from 192.168.0.2
Allow from 10.0.0.1
</Files>
I need help formatting rule with the files/directories containing theword and add exception for the googlebot.

Directive allow from not work for only one ip in .htaccess

I have .htaccess file for wordpress. There is code
<Files wp-login.php>
order deny,allow
deny from all
allow from 46.61.xxx
allow from 91.211.xxx
allow from 176.14.xxx
</files>
2 of these ip - works, i.e. i can enter from 46.61.xxx and 176.14.xxx, but i can't enter from 91.211.xxx. What problem could it be?
Give it a try without those xxx's, check the apache documentation
<Files wp-login.php>
order deny,allow
deny from all
allow from 46.61
allow from 91.211
allow from 176.14
</files>

htaccess visible by Web clients

I just discovered my .htaccess file is publicly visible from web clients (e.g. site/.htaccess ).
I'm running Apache/2.2.22 with mod_fcgid.
htaccess is working, if I put garbage in it I get Internal Server Error.
It seems these lines inside apache2.conf are ignored:
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
Any hint?
Update
Inside conf.d directory there's a configuration file blocking some spambots and some ip ranges.
<Location />
Order allow,deny
Allow from all
# Forum Spambots
deny from IP-RANGE
deny from env=bad_bot
</Location>
How can I still block .htaccess and .htpasswd from being visible from web clients?

htaccess Deny All for certain files and allow by IP for the rest

I've recently upgraded a web app and I want to combine the new and old htaccess into one file. Here is my new htaccess:
<Files ~ "\.inc$">
Order allow,deny
Deny from all
</Files>
And my old htaccess:
order deny,allow
deny from all
Allow from 12.34.567.89
Allow from 12.34.567.88
My end goal is that No One can access the *.inc but only the approved IPs can access the rest of the folder.
Can I just concatenate these two rules in one file?
Yes you can use:
order deny,allow
deny from all
Allow from 12.34.567.89
Allow from 12.34.567.88
<Files ~ "\.inc$">
Order allow,deny
Deny from all
</Files>

Blocked my country for .htaccess?

I have generated blocked some country list on ip2location for .htaccess file.Everything it's ok but if I blocked my country ,how can I access on my computer in my country? Do you have any idea for .htaccess settings?
<Limit GET HEAD POST>
order allow,deny
allow from all
deny from 1.0.1.0/24
deny from 1.0.2.0/23
deny from 1.0.8.0/21
</Limit>

Resources