Guide on How to Restrict Website Access Based on IP

In this discussion, you need access that can connect to a hosting account, such as an FTP Client or Cpanel and of course you must also know the static IP, because if the IP address entered is a dynamic IP, it is possible that this method will not work as expected.

After connecting to the hosting account. If you are connected via Cpanel, you can open the File Manager in the Files column, then find the .htaccess file in the public_html directory.




Next, enter the IP in the .htaccess file. if you don't know how to check the IP, you can check it online or at this URL https://whatismyipaddress.com/.

After that, add the following code to the .htaccess file.

Order Deny,Allow
Deny from all
Allow from YourIP

Change YourIP to the IP you want to use and save the file changes. If you can't access the website, try checking your IP again. If it has changed, then your IP is a dynamic IP.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.