WordPress · 18/01/2022

Stop Spam and Hackers IP Blacklist for WordPress

Stop Spam and Hackers IP Blacklist for WordPress

These IPs  will try to spam your comments and try to find week spots in .php files, it is better to block CDIR Range or apply full ip bann: Range specified with hyphen (dash), ex: 20.192.0.0 – 20.255.255.255

Info:
We will update the list every day if is possible.

This ips will try to:

  1. Spam comments 
  2. Attempt to access prohibited URL for vulnerabilities: wp-config.php, admin.php, /env/ etc…
See the full IPs list:
2.56.56.0/22
2.56.58.0 – 2.56.59.255
2.57.136.0 – 2.57.137.255
3.109.16.225
3.128.0.0 – 3.255.255.255
3.224.0.0 – 3.239.255.255
5.56.56.0 – 5.56.59.255
5.101.157.0 – 5.101.157.255
5.133.123.0 – 5.133.123.255
5.181.168.0 – 5.181.168.255
5.181.169.0 – 5.181.169.255
5.181.170.0 – 5.181.170.255
5.183.252.0 – 5.183.252.255
5.188.62.0 – 5.188.62.255
5.188.211.0 – 5.188.211.255
5.189.128.0 – 5.189.143.255
5.189.239.0 – 5.189.239.255
8.208.0.0 – 8.223.255.255
13.64.0.0 – 13.107.255.255
13.64.0.0/11
13.96.0.0/13
13.104.0.0/14
13.112.0.0 – 13.115.255.255
15.235.0.0 – 15.235.255.255
15.235.35.0 – 15.235.35.255
20.0.0.0 – 20.31.255.255
20.33.0.0 – 20.128.255.255
20.33.0.0/16
20.34.0.0/15
20.36.0.0/14
20.40.0.0/13
20.48.0.0/12
20.64.0.0/10
20.128.0.0/16
20.192.0.0 – 20.255.255.255
23.92.208.0 – 23.92.223.255
23.96.0.0 – 23.103.255.255
23.104.0.0 – 23.105.191.255
24.80.0.0 – 24.87.255.255
27.254.85.0 – 27.254.85.255
31.24.46.0 – 31.24.46.255
31.40.248.0 – 31.40.249.255
31.210.20.0 – 31.210.21.255
34.64.0.0 – 34.127.255.255
37.9.44.0 – 37.9.44.255
37.9.45.0 – 37.9.45.255
37.44.196.0 – 37.44.197.255
37.44.252.0 – 37.44.253.255
37.115.64.0 – 37.115.127.255
37.120.203.0 – 37.120.203.255
37.190.208.0 – 37.190.215.255
37.192.176.0 – 37.192.183.255
39.64.0.0 – 39.95.255.255
40.74.0.0 – 40.125.127.255
40.74.0.0/15
40.76.0.0/14
40.80.0.0/12
40.96.0.0/12
40.112.0.0/13
40.117.158.190
40.120.0.0/14
40.124.0.0/16
40.125.0.0/17
42.200.128.0 – 42.200.255.255
43.129.64.0 – 43.129.127.255
43.241.56.0 – 43.241.59.255
43.249.24.0 – 43.249.24.255
45.10.164.0 – 45.10.164.255
45.10.166.0 – 45.10.166.255
45.10.167.0 – 45.10.167.255
45.43.0.0 – 45.43.31.255
45.43.8.0 – 45.43.8.255
45.55.0.0 – 45.55.255.255
45.66.208.0 – 45.66.208.255
45.66.210.0 – 45.66.210.255
45.76.0.0 – 45.77.255.255
45.76.180.0 – 45.76.181.255
45.84.190.0 – 45.84.191.255
45.123.148.0 – 45.127.175.255
45.130.83.0 – 45.130.83.255
45.132.186.0 – 45.132.186.255
45.138.100.0 – 45.138.100.255
45.138.102.0 – 45.138.102.255
45.140.206.0 – 45.140.207.255
45.142.92.0 – 45.142.99.255
45.144.225.0 – 45.144.225.255
45.148.126.0 – 45.148.126.255
45.148.232.0 – 45.148.233.255
45.148.234.0 – 45.148.235.255
45.224.0.0 – 45.230.11.255
45.248.148.0 – 45.250.23.255
46.4.99.128 – 46.4.99.159
46.71.0.0 – 46.71.255.255
46.102.157.192 – 46.102.157.255
46.161.11.0 – 46.161.11.255
46.161.14.0 – 46.161.15.255
46.161.60.0 – 46.161.60.255
46.161.61.0 – 46.161.61.255
47.74.0.0 – 47.87.255.255
47.75.0.0 – 47.75.255.255
47.88.0.0 – 47.88.127.255
47.88.0.0 – 47.91.255.255
47.182.0.0 – 47.190.255.255
47.250.0.0 – 47.254.255.255
47.251.0.0 – 47.251.255.255
49.156.32.0 – 49.156.32.255
50.28.0.0 – 50.28.127.255
50.87.0.0 – 50.87.255.255
50.117.0.0 – 50.117.127.255
50.117.114.160 – 50.117.114.167
50.118.128.0 – 50.118.255.255
50.118.178.0 – 50.118.178.255
51.68.11.0 – 51.68.11.255
51.222.0.0 – 51.222.255.255
52.0.0.0 – 52.79.255.255
52.132.0.0 – 52.143.255.255
52.145.0.0 – 52.191.255.255
52.145.0.0/16
52.146.0.0/15
52.148.0.0/14
52.152.0.0/13
52.160.0.0/11
52.224.0.0 – 52.255.255.255
54.37.121.0 – 54.37.121.255
54.144.0.0 – 54.221.255.255
54.144.0.0/12
54.160.0.0/11
54.192.0.0/12
54.208.0.0/13
54.216.0.0/14
54.220.0.0/15
54.221.0.0 – 54.221.255.255
54.224.0.0 – 54.255.255.255
61.90.0.0 – 61.90.68.255
61.254.160.0 – 61.255.255.255
62.113.116.0 – 62.113.116.255
62.171.128.0 – 62.171.159.255
62.210.0.0 – 62.210.127.255
62.210.128.0 – 62.210.255.255
62.233.50.0 – 62.233.50.255
63.141.224.0 – 63.141.255.255
63.141.251.184 – 63.141.251.191
66.29.128.0 – 66.29.159.255
66.33.192.0 – 66.33.223.255
66.188.0.0 – 66.191.255.255
66.190.80.0 – 66.190.95.255
67.205.128.0 – 67.205.191.255
68.96.0.0 – 68.111.255.255
68.111.128.0 – 68.111.255.255
69.12.64.0 – 69.12.95.255
69.30.192.0 – 69.30.255.255
69.30.230.56 – 69.30.230.63
69.197.128.0 – 69.197.191.255
69.197.160.224 – 69.197.160.231
70.160.0.0 – 70.191.255.255
70.163.128.0 – 70.163.255.255
72.167.0.0 – 72.167.255.255
74.91.16.0 – 74.91.31.255
74.91.29.8 – 74.91.29.15
74.208.0.0 – 74.208.255.255
77.81.136.0 – 77.81.136.127
77.220.192.0 – 77.220.192.255
77.220.195.0 – 77.220.195.255
78.31.88.0 – 78.31.95.255
78.110.48.0 – 78.110.55.255
78.138.40.0 – 78.138.40.255
79.110.31.128 – 79.110.31.255
80.253.248.0 – 80.253.251.255
81.30.134.128 – 81.30.134.191
81.88.52.0 – 81.88.53.255
82.102.25.0 – 82.102.25.255
82.118.29.0 – 82.118.29.255
82.165.64.0 – 82.165.127.255
82.196.0.0 – 82.196.15.255
83.142.52.0 – 83.142.53.255
83.171.224.0 – 83.171.224.255
83.171.226.0 – 83.171.226.255
83.171.227.0 – 83.171.227.255
83.171.252.0 – 83.171.253.255
83.216.185.56 – 83.216.185.95
84.16.242.64 – 84.16.242.255
84.17.48.0 – 84.17.49.255
84.17.58.0 – 84.17.59.111
84.54.58.0 – 84.54.58.255
85.132.224.0 – 85.132.255.255
85.206.163.144 – 85.206.163.159
85.208.85.0 – 85.208.85.255
85.209.88.0 – 85.209.88.127
87.98.251.0 – 87.98.251.255
87.251.84.0 – 87.251.85.255
88.198.0.0 – 88.198.15.255
88.218.47.0 – 88.218.47.255
89.107.229.0 – 89.107.229.255
89.187.176.0 – 89.187.179.255
89.187.180.0 – 89.187.183.255
89.191.226.0 – 89.191.226.255
89.238.178.0 – 89.238.178.255
90.154.0.0 – 90.154.127.255
90.154.72.0/23
91.90.123.0 – 91.90.123.255
91.123.16.0 – 91.123.31.255
91.132.184.0 – 91.132.187.255
91.134.214.32 – 91.134.214.47
91.134.248.0 – 91.134.248.255
91.204.14.0 – 91.204.14.255
91.212.213.0 – 91.212.213.255
91.222.236.0 – 91.222.236.255
91.223.89.0 – 91.223.89.255
91.239.206.0 – 91.239.207.255
91.243.191.0 – 91.243.191.255
91.246.208.0 – 91.246.215.255
92.38.136.64 – 92.38.136.79
92.204.0.0 – 92.204.63.255
92.204.160.0/19
92.204.174.80 – 92.204.174.95
92.205.0.0 – 92.205.31.255
92.223.85.0 – 92.223.85.255
93.89.192.0 – 93.89.203.255
93.124.64.0 – 93.124.127.255
93.177.116.0 – 93.177.117.255
93.177.118.0 – 93.177.119.255
94.26.228.0 – 94.26.228.255
94.103.81.0 – 94.103.81.255
94.137.72.0 – 94.137.72.255
94.138.203.0 – 94.138.203.255
94.143.192.0 – 94.143.192.255
94.158.22.0 – 94.158.22.255
94.181.32.0 – 94.181.47.255
95.105.96.0 – 95.105.127.255
95.128.161.0 – 95.128.161.255
95.128.163.0 – 95.128.163.255
95.128.165.0 – 95.128.165.255
95.141.131.0 – 95.141.131.255
95.142.121.0 – 95.142.121.255
95.152.8.0 – 95.152.63.255
95.152.32.0/20
95.167.178.0 – 95.167.178.255
95.173.160.0 – 95.173.160.255
95.214.8.0 – 95.214.8.255
95.216.0.0 – 95.217.255.255
102.129.128.0 – 102.129.255.255
102.250.0.0 – 102.250.255.255
103.1.236.0 – 103.1.239.255
103.51.103.0 – 103.51.103.255
103.107.198.0 – 103.107.198.255
103.108.92.0 – 103.108.92.255
103.121.88.0 – 103.121.91.255
103.121.90.0/23
103.137.184.0 – 103.137.185.255
103.147.12.0 – 103.147.13.255
103.159.224.0 – 103.159.225.255
103.209.9.0 – 103.209.9.255
104.154.0.0 – 104.155.255.255
104.236.0.0 – 104.236.255.255
104.238.64.0 – 104.238.127.255
104.238.204.0 – 104.238.207.255
104.254.244.0 – 104.254.247.255
107.150.0.0 – 107.150.31.255
107.150.28.0 – 107.150.29.255
107.150.32.0 – 107.150.63.255
107.150.48.232 – 107.150.48.239
107.150.71.0 – 107.150.71.255
107.180.0.0 – 107.180.127.255
107.182.128.0 – 107.182.128.255
107.182.128.0 – 107.182.131.255
109.70.144.0 – 109.70.151.255
109.86.217.0 – 109.86.217.255
109.107.188.0 – 109.107.188.255
109.162.64.0 – 109.162.127.255
109.194.136.0 – 109.194.143.255
109.205.180.0 – 109.205.183.255
109.234.162.0 – 109.234.162.255
109.248.12.0 – 109.248.13.255
109.253.128.0 – 109.253.255.255
112.144.0.0 – 112.159.255.255
113.60.0.0 – 113.60.255.255
116.206.228.0 – 116.206.228.255
119.13.192.0 – 119.13.223.255
121.196.0.0 – 121.199.255.255
128.199.0.0 – 128.199.255.255
132.145.0.0 – 132.145.255.255
132.148.0.0 – 132.148.255.255
133.167.92.0 – 133.167.92.255
134.236.0.0 – 134.236.255.255
136.144.17.0 – 136.144.17.255
136.169.192.0 – 136.169.223.255
137.74.0.0 – 137.74.255.255
137.184.0.0 – 137.184.255.255
138.59.0.0 – 138.59.255.255
138.128.160.0 – 138.128.191.255
139.99.0.0 – 139.99.127.255
139.99.0.0 – 139.99.255.255
141.11.28.0 – 141.11.28.255
141.94.87.64 – 141.94.87.95
141.98.84.0 – 141.98.84.255
141.98.87.0 – 141.98.87.255
142.93.0.0 – 142.93.255.255
144.76.0.0/16
144.76.191.16 – 144.76.191.23
144.217.0.0 – 144.217.255.255
145.239.19.0 – 145.239.19.63
146.70.25.0 – 146.70.25.255
146.70.29.0 – 146.70.29.255
146.70.83.0 – 146.70.83.255
147.78.183.0 – 147.78.183.255
147.135.0.0 – 147.135.127.255
147.135.36.0 – 147.135.39.255
147.182.128.0 – 147.182.255.255
148.66.128.0 – 148.66.159.255
148.72.0.0 – 148.72.255.255
152.39.128.0 – 152.39.255.255
154.6.16.151
154.6.17.202
154.13.1.159
154.38.0.0 – 154.38.255.255
156.146.48.0 – 156.146.49.255
156.146.56.0 – 156.146.57.255
157.1.0.0 – 157.14.255.255
157.245.0.0 – 157.245.255.255
158.69.0.0 – 158.69.255.255
158.69.241.*
158.255.215.0 – 158.255.215.255
159.65.0.0 – 159.65.255.255
159.75.0.0 – 159.75.255.255
159.89.0.0 – 159.89.255.255
159.223.0.0 – 159.223.255.255
159.253.24.0 – 159.253.25.255
162.144.0.0 – 162.144.255.255
162.212.170.0 – 162.212.170.255
162.240.0.0 – 162.241.255.255
162.251.80.0 – 162.251.86.255
163.0.0.0 – 163.255.255.255
164.132.0.0 – 164.132.255.255
165.22.0.0 – 165.22.255.255
165.231.0.0 – 165.231.255.255
167.71.0.0 – 167.71.255.255
167.99.0.0 – 167.99.255.255
168.151.157.0 – 168.151.187.255
168.151.157.0/24
168.151.158.0/23
168.151.160.0/20
168.151.176.0/21
168.151.184.0/22
172.32.0.0 – 172.63.255.255
172.83.53.61
172.255.112.0 – 172.255.135.255
172.255.124.0 – 172.255.127.255
172.255.125.176 – 172.255.125.183
173.201.0.0 – 173.201.255.255
173.208.128.0 – 173.208.255.255
173.208.153.152 – 173.208.153.159
173.212.224.0 – 173.212.255.255
173.244.32.0 – 173.244.63.255
173.244.55.0 – 173.244.55.255
173.249.0.0 – 173.249.31.255
173.249.32.0 – 173.249.63.255
174.128.224.0 – 174.128.255.255
174.138.0.0 – 174.138.127.255
176.31.96.0 – 176.31.127.255
176.105.192.0 – 176.105.223.255
176.106.240.0 – 176.106.255.255
176.116.230.0 – 176.116.231.255
176.119.141.0 – 176.119.141.255
176.214.136.0 – 176.214.143.255
177.55.96.0/19
178.33.224.0 – 178.33.239.255
178.62.0.0 – 178.62.127.255
178.128.16.0 – 178.128.31.255
178.128.96.0 – 178.128.111.255
178.150.102.0 – 178.150.102.255
178.159.37.0 – 178.159.37.255
178.159.100.0 – 178.159.100.255
178.210.64.0 – 178.210.92.255
178.210.80.0/21
178.210.160.0 – 178.210.191.255
180.149.0.0 – 180.149.31.255
180.178.128.0 – 180.178.191.255
182.48.49.0 – 182.48.49.255
184.168.0.0 – 184.168.255.255
185.59.47.0 – 185.59.47.255
185.61.154.0 – 185.61.155.255
185.61.216.0 – 185.61.216.255
185.61.218.0 – 185.61.218.255
185.61.220.0 – 185.61.220.255
185.61.223.0 – 185.61.223.255
185.65.135.0 – 185.65.135.255
185.66.68.0 – 185.66.69.255
185.68.184.0 – 185.68.184.255
185.68.185.0 – 185.68.185.255
185.68.246.0 – 185.68.246.255
185.68.247.0 – 185.68.247.255
185.81.0.0 – 185.81.7.255
185.81.144.0 – 185.81.144.255
185.81.145.0 – 185.81.145.255
185.83.144.0 – 185.83.144.255
185.88.102.0 – 185.88.102.255
185.89.100.0 – 185.89.100.127
185.89.100.128 – 185.89.100.255
185.94.99.0 – 185.94.99.127
185.96.37.0 – 185.96.37.255
185.96.218.0 – 185.96.219.255
185.102.112.0 – 185.102.112.255
185.102.113.0 – 185.102.113.255
185.103.199.0 – 185.103.199.255
185.119.81.0 – 185.119.81.255
185.136.84.0 – 185.136.84.255
185.191.34.0 – 185.191.35.255
185.191.228.0 – 185.191.231.255
185.191.231.0/24
185.246.172.0 – 185.246.175.255
185.250.44.0 – 185.250.45.255
185.250.46.0 – 185.250.47.255
185.255.96.0 – 185.255.97.255
187.73.32.0/20
188.93.64.0 – 188.93.67.255
188.126.64.0 – 188.126.95.255
188.126.73.128 – 188.126.73.255
188.163.64.0 – 188.163.64.255
188.163.73.0 – 188.163.73.255
188.166.176.0 – 188.166.191.255
188.166.224.0 – 188.166.239.255
188.172.220.64 – 188.172.220.79
188.212.136.0 – 188.212.143.255
188.214.152.0 – 188.214.152.255
191.240.0.0/17
192.227.128.0 – 192.227.255.255
192.227.156.24 – 192.227.156.31
192.241.128.0 – 192.241.255.255
193.31.126.0 – 193.31.126.255
193.34.145.0 – 193.34.145.255
193.36.118.0 – 193.36.118.255
193.56.73.0 – 193.56.73.255
193.93.192.0 – 193.93.192.255
193.93.195.0 – 193.93.195.255
193.142.58.0 – 193.142.58.255
193.188.21.0 – 193.188.21.255
193.188.22.0 – 193.188.22.255
193.202.80.0 – 193.202.81.255
193.202.82.0 – 193.202.83.255
193.202.110.0 – 193.202.110.255
193.203.8.0 – 193.203.9.255
193.203.10.0 – 193.203.11.255
194.99.24.0 – 194.99.24.255
194.99.26.0 – 194.99.26.255
194.99.44.0 – 194.99.45.255
194.104.11.0 – 194.104.11.255
194.110.169.0 – 194.110.169.255
194.113.235.0 – 194.113.235.255
194.163.128.0 – 194.163.159.255
194.190.90.0 – 194.190.90.255
194.190.179.0 – 194.190.179.255
195.2.71.0 – 195.2.71.255
195.2.76.0 – 195.2.76.255
195.181.163.0 – 195.181.163.191
195.181.172.0 – 195.181.173.255
195.246.120.0 – 195.246.121.255
198.23.128.0 – 198.23.255.255
198.23.240.192 – 198.23.240.255
198.57.128.0 – 198.57.255.255
198.71.128.0 – 198.71.255.255
198.136.48.0 – 198.136.63.255
199.33.112.0 – 199.33.115.255
199.33.112.224 – 199.33.112.255
199.192.16.0 – 199.192.31.255
200.10.36.0/23
200.10.41.0/24
200.73.0.0/19
200.107.206.0/24
200.114.224.0/19
201.20.176.0/20
201.149.32.0/19
202.172.28.0 – 202.172.31.255
203.78.168.0 – 203.78.175.255
204.12.192.0 – 204.12.255.255
204.12.202.88 – 204.12.202.95
204.12.215.56 – 204.12.215.63
208.109.0.0 – 208.109.255.255
209.160.106.0 – 209.160.107.255
212.83.144.0 – 212.83.159.255
212.115.51.0 – 212.115.51.255
212.119.44.0 – 212.119.45.255
212.119.46.0 – 212.119.47.255
212.192.240.0 – 212.192.243.255
212.193.28.0 – 212.193.31.255
213.108.0.0 – 213.108.0.255
213.108.3.0 – 213.108.3.255
213.149.103.128 – 213.149.103.255
213.178.40.0 – 213.178.40.255
213.232.120.0 – 213.232.120.255
213.232.121.0 – 213.232.121.255
216.158.224.0 – 216.158.239.255
216.194.80.0 – 216.194.95.255
217.138.217.0 – 217.138.217.255
217.145.224.0 – 217.145.224.255
217.145.227.0 – 217.145.227.255
219.75.192.0 – 219.75.255.255
219.114.208.0 – 219.114.223.255
221.208.0.0 – 221.212.255.255
221.208.0.0/14
2001:67c:2660::/48
2001:19f0:6:b::bd8a
2001:41d0::/32
2001:41d0::/44
2400:6180:100::/40
2400:8901::/32
2600:3C00::/28
2600:8805:c00:4e90:c88a:ccaa:691a:82ee
2601:2c3:c200:b380:6819:7187:f14d:5d3a
2603:8000::/24
2604:7C00::/32
2605:6400::/28
2607:5300:60:ca92::
2607:F1C0:: – 2607:F1C0:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF
2607:FB90::/28
2800:6c0::/32
2a00:f10::/29
2a00:d680::/32
2a00:d680:10::/48
2a01:4f8::/29
2a01:7c8::/29
2a02:4780:1::/48
2a02:4780:3::/48
2a02:4780:8::/48
2a02:4780:9::/48
2a02:4780:a::/48
2a03:7720::/48
2a05:d000::/25
2a06:dd00::/30
2a09:8700::/32
2a09:8700:1::/48
2a09:8b00:300:1::/64
2a0b:7280::/29
2a0d:7c40::/29

How to Block IP Address with .htaccess

Quick post today showing some different ways to block visitors via their IP address. This can be useful for a variety of reasons, including stopping some stupid script kiddie from harassing your site, or preventing some creepy stalker loser from lurking around your forums, or even silencing the endless supply of angry trolls that never seem to get a clue. So many reasons why, and so many ways to block them. Continue reading to learn how to block any IP address using a thin slice of .htaccess.

 

Block a specific IP address

This is the one that most visitors to this page will want to use:

Deny from 123.123.123.123

Just change the IP address to the one that you want to block, and then add the code to your site’s root .htaccess file.

Block a specific domain

To block a specific domain, add the following to your site’s root .htaccess file:

Deny from 123.123.123.123/255.255.255.0

Then change the IP address and netmask values to match the domain that you want to block.

Block multiple IP addresses

If you’ve got more than one IP address that you would like to block, you can deny them all at once:

Deny from 111.111.111.111 222.222.222.222 333.333.333.333

This will block the three specified IPs: 111.111.111.111222.222.222.222, and 333.333.333.333. Edit the IPs to match the ones that you want to block, and then add the line to your .htaccess file.

Block entire subnet

It’s also possible to block an entire range of IPs. Here is an example where we block every IP that begins with 123.123:

Deny from 123.123

To block multiple ranges, we can do this:

Deny from 111 222.222 333.333.333

Once you get the pattern, the sky’s the limit. Just be mindful of what you’re doing; blocking an entire range of IPs is serious business.

Block IP based on CIDR

If you know the specific CIDR for the IP that you are trying to block, you can use this syntax:

Deny from 123.123.123.0/24

As with all of these rules, you can edit to match your target and then add to .htaccess.

Block IPv6 addresses

IPv6 addresses are more commonly used every day. If you want to block one via .htaccess, here is the proper syntax:

Deny from 2001:0db8:0000:0042:0000:8a2e:0370

You can also use either of these notations, depending on the target:

Deny from 2001:0db8:0000:0042
Deny from 2001:0db8:0000:0042:0000/10

Block IP based on regular expression

This IP-blocking method tests all addresses against a predefined regular expression via RewriteCond/RewriteRule directives:

<IfModule mod_rewrite.c>
	RewriteCond %{REMOTE_ADDR} ^214.53.25.(6[4-9]|7[0-9]|8[0-9]|9[0-9])$ [OR]
	RewriteCond %{REMOTE_ADDR} ^214.53.25.1([0-1][0-9]|2[0-8])$
	RewriteRule .* - [F]
</IfModule>

There is probably a more efficient way to write the regular expressions in the previous example, but that should definitely get the job done.

Redirect based on IP address

Instead of blocking visitors based on IP address, you can redirect them to another location. Here’s how to do it using Apache’s mod_rewrite:

<IfModule mod_rewrite.c>
	RewriteCond %{REMOTE_ADDR} ^111\.111\.111\.111$
	RewriteRule .* /index.php [R=301,L]
</IfModule>

You can change the IP of course to match the one you are targeting. And then edit the /index.php to match the URI to which any matching requests should be sent. Here is another example to help illustrate the technique:

<IfModule mod_rewrite.c>
	RewriteCond %{REMOTE_HOST} 123\.123\.123\.123
	RewriteCond %{REQUEST_URI} /requested-page\.html
	RewriteRule .* /just-for-you.html [R=301,L]
</IfModule>

Here we are checking the IP and the requested URI. If there’s a match, then the request will be sent to /just-for-you.html. To use this redirect, simply edit the IP address, requested page, and redirect page. Copy and paste the code into your .htaccess file and upload to your server.

Block specific request types

Let’s say that you only want to block some visitor from, say, posting content via a form on your site. That can be done by using Apache’s <Limit> container:

<Limit POST>
	Order Allow,Deny
	Allow from all
	Deny from 123.123.123.123
</Limit>

Notice the POST specified in the <Limit> container? That’s the key, and you can change that to target any request type.

Here is an example of the inverse case, where we want to allow posting from only our own IP address, while denying POST requests for everyone else:

<Limit POST>
	Order Deny,Allow
	Deny from all
	Allow from 111.111.111.111
</Limit>

Notice the reversal of the Order directive: here we are denying first, then allowing, which provides the logic required for this technique.

Complete notation

While it’s fine to simply add a single line, like Deny from 123.123 in your .htaccess file, there is a more complete syntax that can be used. Here are a couple of examples:

Order Allow,Deny
Allow from all
Deny from 123.123.123.123/26

Notice the extra logic involved with this more “correct” syntax: here we are specifying the Oder directive, which enables us to change Apache’s default order, which is Allow,Deny. So when we include only a single Deny from line (as in our previous examples), it works because we are using the default order of Allow,Deny. That’s why it’s fine to exclude the extra lines. Or, if desired, we could change the order explicitly:

Order Deny,Allow
Deny from all
Allow from 111.111.111.111

Here we first deny access to everyone, and then allow only the specified address. Combining this syntax with the <Limit> container, we can do cool things like enable POST and PUT requests only from our own IP address. For example:

<Limit POST PUT>
	Order Deny,Allow
	Deny from all
	Allow from 111.111.111.111
</Limit>

Combining these techniques with previous examples, your IP-blocking powers are complete.

Reminder

Remember to always make a backup of anything that you intend to modify, and then test well before going live with any new rules. Play it safe and have some fun.

Stop Spam and Hackers IP Blacklist for WordPress