Lawrence Wright

  • About Me
  • Portfolio
  • Services
  • My Blog
  • Facebook
  • Twitter
  • Email
  • Subscribe RSS
Jan 23, 2013
0  
  • Facebook
  • Twitter

How to Restrict Access Using .htaccess

Restricting access to a website using a .htaccess file is easy. Below is a code snippet to show you how to restrict access using .htaccess. Refer to the code below, and copy + paste it into your .htaccess file. Follow these instructions.

.htaccess Creation

  1. Create a .htaccess file in the directory you wish to protect.
  2. Copy the following code and paste it into your .htaccess file.

<limit GET>
order deny,allow
deny from all
allow from 1.1.1.1
allow from 1.1.1.2
</limit>

Now that you have a .htaccess file with pre-filled code, replace the rows that say allow from with IP addresses you wish to have access to your directory. Add the IPs right after allow from.

The deny,allow is important, since you're denying access first, then allowing access. You first deny all access to your directory, then allow specific IPs through the block you've set. This is great security practice, and ensures only those you specify are able to access your directory's contents.

For additional information on working with .htaccess files, you can find documentation on the official Apache website. This resource contains a lot of useful information, and could answer some unanswered questions you may have.

Apache.org .htaccess Documentation

Related Posts

  • How to Restrict Access Us...

    Restricting access to a website using a .htaccess file is easy. Below is a code snippet to show you how to restrict access using .htaccess. Refer to the code below, and copy + paste it into your .htaccess file. Follow these instructions.

    Find out more
  • How To Advertise Your Web...

    This is my first blog post, so I thought I'd get the gun rolling with useful information any webmaster with a stiff budget can use.  I'm going to explain what techniques are best in the order of least preferred to most desired.  Read up and take it all in, it's actually very easy stuff!

    Find out more

Category

Crypto Currency
Drupal
Games
Linux
Personal
Reviews
Security
Social Media
Webmasters
Websites
WordPress
Writing

Lawrence Wright © 2014. All Rights Reserved.

Terms | Privacy