If someone is attempting to hack your website, or you need to block a specific IP address from accessing your site, you can do so by adding the following lines to your .htaccess file. This method is effective for Apache web servers and is commonly used to enhance website security.
order allow,denydeny from IP-ADDRESSallow from all
Replace IP-ADDRESS with the actual IP address you wish to block. For example, to block 192.168.1.100, use:
deny from 192.168.1.100
Note: After making changes to your .htaccess file, be sure to test your website to ensure it is still accessible to legitimate users. Blocking IP addresses is a basic security measure and may not prevent all types of attacks. For more advanced protection, consider using a web application firewall (WAF) or security plugins if you are using WordPress.