|
Answer
by: Andrew Hickl, Aplus.Net Knowledge Base Support.
.htaccess
files can be used to block traffic from specific IP addresses that may
be trying accessing your site maliciously.
Here’s
how to do it:
- Start by
editing the .htaccess file in the directory you’re looking to
customize. (We recommend editing it using the
“Edit” function found in the File Manager on the
Control Panel.) If you currently do not have a .htaccess file, create one
locally using a text editor like NotePad (Windows), SimpleText
(Macintosh) or Emacs (Linux / UNIX).
- Next, enter
the following code into your .htaccess file:
|
order
allow,deny
deny from
domain.com
allow from
domain.com
|
You
will need to replace ‘domain.com’ in the code above
with either the IP address or the domain name of the site(s) that you
want to grant or deny access to your site. If
you’re granting / denying access to several individual sites,
you’ll need to make each request on an individual line, as in
the following example:
|
order
allow,deny
deny from
216.55.129.46
deny from
aplus.net
allow from
66.83.239.66
allow from
apluskb.com
|
In order to grant / deny access to all users, simply replace
‘domain.com’ in the above examples with the word
‘all’. For example:
|
order
allow,deny
deny from
apluskb.com
allow from
all
|
In
the example above, traffic from originating at http://apluskb.com is
blocked,
but all other traffic is permitted.
- Save your
.htaccess file to your local computer.
- Open your FTP
client and establish a connection to your web space using your FTP
Username and FTP Password. Your connection URL should be www.yourdomainname.com
(where ‘yourdomainname.com’ = the actual name of
your domain).
- Browse to the
directory that you’d like to customize.
- Set your
upload settings to ASCII. (Uploading .htaccess files in
‘binary’ format may have unexpected consequences.)
- Upload your
.htaccess file from your local computer.
- After the
upload is completed, you may need to change the file permissions for
the .htaccess file. They should be set to 644 (using chmod)
or RW-R--R--.
Note:
If you have a Windows-based hosting plan, you cannot use .htaccess
files.
|