How to restrict access to your site using .htaccess except your IP address?
Restriction in .htaacess file applies to any IP address, including yours. Find out your IP address using tools like "What Is My IP Address
" and create an exception for yourself.
Make sure that your IP address is static, not dynamic, so you wouldn’t have to change it in the .htaccess file frequently.
In the next step, you need to find .htaacess file.
1. Login into your cPanel account
2. Click on „File manager“ in the „File“ section
3. In the right top click on „Settings“.
4. Mark „Show hidden settings (dotfiles)“
5. Find the .htaacess file, default dirrectory , that is home/public_html
, but it may be differ depending the settings. Wen you found the file click on it with right mouse button and choose „Edit“.
6. Now, let’s place the deny from all command in the .htaccess file. Add the following code snippet to the top of the file if you want to block all access except yours (replace <your ip>
with your IP address to create the exception):
7. Click on „Save changes“.Note:
To remove restrictions, just delete the inserted lines of the rule from the document and save the changes.