Question
How do you restrict access to a website by IP?
Answer
- Access the server's command line as the cPanel user via SSH or Terminal in cPanel.
- Open the site's
.htaccessfile in your preferred text editor. -
Add the following to the
.htaccessfile:CONFIG_TEXT: <RequireAll>
Require all granted
Require not ip 203.0.113.2
</RequireAll>Note: "203.0.113.2" must be replaced by the IP address to block.
- Save the changes and exit the text editor.
Note: If the domain uses Cloudflare for its DNS, because Cloudflare proxies the connection, this would not work without disabling their proxy service.
Comments
0 comments
Article is closed for comments.