Htaccess Introduction

The main purpose of .htaccess file was to allow per-directory access control. ".htaccess" files affect the directory and sub-directories in which it is placed.

Use of Htaccess.

  • Authorization, Authentication : A ".htaccess" file is often used to specify security restrictions for a directory. The .htaccess file is uses a ".htpasswd" file which stores valid usernames and their passwords .
  • Rewriting urls : We use ".htaccess" file to rewrite long, complicated urls to shorter and more memorable ones.
  • Blocking : By ".htaccess" file we can block users by IP address or domain. Also, use to block bad bots, referrers and rippers.
  • SSI : Enable server-side includes.
  • Directory listing : ".htaccess" file Control how the server will react when no specific web page is specified.
  • Customize error pages : ".htaccess" file used to customize the page that is shown when a server-side error occurs.
  • Cache control : ".htaccess" file allow a server to control caching by web browsers and proxies to reduce bandwidth usage.