Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Blocking an IP address in the .htaccess file is a common way to prevent unwanted traffic from reaching your website. Here are the steps to block an IP address using the .htaccess file:

Access Your .htaccess File:

...

To block a specific IP address, add the following lines to your .htaccess file:


Code Block
<Limit<Limit>
GET POST>
order deny,allow
deny from 123.456.789.000
allow from all
</Limit>

...

You can block multiple IP addresses by adding additional deny from lines:

Code Block
<Limit<Limit>
GET POST>
order deny,allow
deny from 123.456.789.000
deny from 111.222.333.444
allow from all
</Limit>

...

You can use a proxy service or ask someone with the specific IP address to test it.

Additional Notes

Blocking an IP Range: If you need to block an entire range of IP addresses, you can use CIDR notation or a partial IP match:

...

Be careful when editing the .htaccess file as incorrect configurations can lead to website downtime or other issues. Always keep a backup of the original .htaccess file before making any changes.

By following these steps, you can effectively block specific IP addresses from accessing your website using the .htaccess file.