Friday, May 17, 2013

Hyper Text Access(htaccess)

In this post we will see how to protect Document Root directory on web servers running the Apache Web Server software.

image

What is htaccess ?

  1. htaccess stands for hypertext access.
  2. .htaccess is a configuration file for use on web servers running the Apache Web Server software.This is the default name of the Apache directory-level configuration file.

This .htaccess file can be used to create security restrictions for directories(/var/www). One of the common use of .htaccess  is to require user authentication in order to secure certain web pages.

Content of htaccess file ?

AuthType Basic

AuthName “Restricted web page”

AuthUserFile /etc/apache2/.htpasswd

require valid-user

Implementation .htaccess ?

Step 1: Create an .htaccess file similar to the one above.

image

Step 2: Create the .htpasswd file containing usernames & password necessary for the authentication.

image

Step 3: Place .htaccess in the directory we wish users to validate before accessing the content.

image

Step 4: Tell httpd to allow user authentication via .htaccess files.

image

Step 5: Restart the server.

image

Step 6: Test the results.

image

image 

Once we are authenticated then it’s displaying the indexes of 2 different websites. If we further move through then it will  display the webpages of respective websites.

http://192.168.56.102/Website1

http://192.169.56.102/Website2

image

image

In the forthcoming posts we will discuss about securing web servers in detail  with step by step examples.
If you have queries about this any topic just leave a reply !!

No comments:

Post a Comment