Here we discuss a method for blocking or allowing an IP address from visiting a site. This method involves editing the .htaccess file associated with the specific site the modification is needed for. Access to cPanel will be needed to complete this process which uses the File Manager utility.
Making this change is particularly useful if an IP address is spamming the site with brute force attempts or malicious requests.
Related Articles
Find the Document Root of a Domain
Edit File with File Manager
Show Hidden Files in File Manager
Block or Allow IP Using .htaccess
- Log into cPanel
- Navigate to File Manager, located in the Files section
- Locate the site's Document Root
- Edit the .htaccess file in the sites document root
TIP: If the file doesn't exist, create one. - To block a specific IP Address
- At the top of the file add the following:
deny from [ip]
Replace: You must replace [ip] with the desired IP address.
EXAMPLE:deny from 123.123.123.123
NOTE: Each IP address should be on a separate line.
- At the top of the file add the following:
- To allow a specific IP address
- At the top of the file add the following:
allow from [ip]
Replace: You must replace [ip] with the desired IP address.
EXAMPLE:allow from 123.123.123.123
NOTE: Each IP address should be on a separate line.
- At the top of the file add the following:
TIP: View the following Apache documentation for further information on Apache directives provided by mod_access_compat.
CAUTION: If multiple directives are added to .htaccess, review the Order Directive section in the above Apache documentation to ensure proper understanding.