Prohibit access to a site is not something you routinely do as we build a website to publicize something, is not it? But in some cases it can happen and you need to lock your all access the site and stay active only for you, maybe when testing or installing new plugins.
This tutorial will teach you how to ban access to a website via the .htaccess file. After running this step by step, users will come across the 403 error on your website. So make sure of the reasons that led him to prohibit access.
Before starting, prepare the following:
Access to cPanel of your hosting account or access to the FTP client.
static IP address. If you have a dynamic IP address, this tutorial may not work for you.
The file .htaccess is in your directory public_html . You can access it using the File Manager in your cPanel or connecting to your account by FTP client such as FileZilla.
Note that the .htaccess is a hidden file, so you need to enable visibility.
You need to know your own IP address to allow yourself able to access your site. In your browser, open the link http://www.whatismyipaddress.com and note its IP address.
Add the following line at the top of your .htaccess file:
Order Deny, Allow Deny from all Allow from YourIPAdress
See below how it would look:
Do not forget to click save changes to save the changes.
IMPORTANT! If you block your own access to your site, make sure your address and IP has not changed. If you have a dynamic IP address, this tutorial is not suitable for you, as we’ve warned earlier.
You learned how to prohibit access to a site, blocking your site to all users except for you. You can also prohibit access to specific countries visitors in this tutorial.