How do I deny access to certain IP addresses? (.htaccess)

This article applies to 123-reg Linux Shared Hosting accounts.

This process is useful if you have information on your website that you only want certain people to see. To set this up, you will need to create a .htaccess file:


Open Notepad or a similar text editor.


Copy and paste the following text into your new .htaccess file:

order allow,deny
deny from
deny from 159.64.9.
allow from all

In your .htaccess file, amend the above code, changing the IP addresses to suit your needs. Each command should be on a separate line.


Save the file with the file name .htaccess.


Ensure that the file type is set to All Files.


Click the Save button.

Tip: You can deny access based upon an IP address or an IP block. The above process blocks access to the site from, and from any subdomain under the IP block 159.64.9. (,, etc.). This can be very useful if there is another site linking directly to your images or content.

You can set an option for Deny From All, which would deny everyone access. You can also allow or deny access by domain name rather than IP address (Allow From works for or, etc).

Answer options

Your feedback was successfully added.

Answer tracking


Watch the content of this article for changes.