Select a topic:

Choose from one of the topics below to browse other articles

Articles & Information.

Block access to your website (using htaccess file)

Last updated by Ashley Cawley on April 24, 2018 09:47

If you would like to block access to your website temporarily or permanently you can do this using what is called a  .htaccess file. To find your .htaccess file login to your cPanel Control Panel and open the File Manager, open your website folder (which is typically a folder called public_html ) in there you should see a file named: .htaccess right-click that file and select 'Code Edit' as shown below:

When you edit the code of the .htaccess file you may see something like this:

The example code shown above is typical of a WordPress website, if you don't use WordPress then it may be that your .htaccess file is empty to start with which is fine.

In order to block access to your site enter a new line at the top of the file and type the following text:

deny from all

And then press the save button.

New visitors to the website will be blocked and will be shown a message that says 'Forbidden - Access to this resource on the server is denied'.

If you want to reverse the process and restore access to your website simply edit the .htaccess file again and put a # symbol in front of the line you created, so it looks like:

# deny from all

The # symbol essentially disables that line and will restore access for visitors to your website.

Allow access to only you

If you would like to block access to the general public but still have access yourself so you can work on your website you can do this by selectively granting access to your IP Address. Your home or office IP Address is a little like your phone number for the internet, you will need to find out your IP Address which is fairly easy to do, to do this visit and search "my ip" and just above the listed search results Google will tell you your public IP Address. Lets say for example that it told you your IP Address was then you would edit your .htaccess file and enter in the following code at the top of your .htaccess file:

order deny,allow

deny from all

allow from

Doing this will block all other visitors to your website apart from yourself.

If you have any difficulty with this please do not hesitate to get in touch and we will do what we can to help.