How do I block an IP address using .htaccess?
Asked on Sep 15, 2025
Answer
To block an IP address using .htaccess, you can use the "deny from" directive within the file. This will prevent the specified IP address from accessing your website.
Order Allow,Deny
Deny from 192.168.1.1
Allow from all
Additional Comment:
- Place the .htaccess file in the root directory of your website.
- Replace "192.168.1.1" with the IP address you wish to block.
- Ensure your server is configured to use .htaccess files (common in Apache setups).
- Use caution when editing .htaccess, as incorrect syntax can cause server errors.
Recommended Links: