Knowledgebase

How to block access to folders on your account

In this article we'll show you how to protect directories on your hosting account by blocking IP addresses from accessing the particular folders.

In this way you can improve the security of folders containing sensitive information (e.g. admin folders). You can block all IPs except yours, or you can give access to several IP addresses or a network of IPs.

First, you need to have an .htaccess file in the directory that you want to block access to. You can create the file from the Files section of the Pixie control panel. To do this, log in to your account's control panel, browse to the directory you want to protect, open it, then click on the Create File link. It's in the black area on the right. After you click on the link, type the name of the file in the text area that's on the page and click on the Create File button. After you do it you'll see a big text area in which you can put the content of the file. Once you do it, click on the Save Contents button or on the Save and Close button. We'll come to what exactly you have to put in the .htaccess file just a bit further down.

You can also create the file with a text editor (e.g. Notepad) on your local computer, and then upload it with an FTP client or with the Pixie control panel.

Don't forget when you name the file to put the dot in front of the name. It should be .htaccess and not htaccess. If there is already an .htaccess file in the directory you want to protect, you can use it. Again, you can edit the file from the Files section of the Pixie control panel, or you can download it with an FTP client, edit it with a text editor, and upload it back.

Here is what you have to put in the .htaccess file (the IP address is just an example):

Order Deny,Allow
Deny from all
Allow from 22.33.44.55

Note that in the first line of the rule there shouldn't be a space between the comma and Allow.

This will block all IP addresses from accessing the directory, except for the one listed (e.g. 22.33.44.55). You can also list several IP addresses, if you want to give access to others. Separate the IPs with a space:

Order Deny,Allow
Deny from all
Allow from 22.33.44.55 66.77.88.99

You can also specify a whole range of IPs that can access the particular directory. Just type the first one to three numbers of the IP address. For example:

Order Deny,Allow
Deny from all
Allow from 22.33 12.34.56

This will allow all IP addresses that begin with 22.33 and those that begin with 12.34.56 to access the directory.

Was this answer helpful?

 Print this Article

Also Read