.htaccess

Guide for beginners

.htaccess is a text file for editing some properties of Apache server – on most of the virtual or dedicated servers as well as on shared hosting.


This file has to be placed in the specific web directory and it allows the website creator to edit directories with the same instructions, that are commonly written in httpd.conf or php.ini files. Directory will be then managed differently without the need of editing the before-mentioned configuration files. It is very easy to create it and it can be edited in most of the text editors and specific programs. The dot on the beginning of the file is important. Simply create a text file with the name of “.htaccess” without the .txt extension.

If you place the .htaccess to the root directory (main directory of the hosting), it will influence the whole hosting. If you place it to any subdirectory, it will take effect only for the subdirectory it is placed in and its subdirectories.

File .htaccess allows

  • create 301 redirect [setup guide]
  • set https protocol with use of SSL certificate [setup guide]
  • set error messages for the website like 404 error [setup guide]
  • restrict access to the website for specific IP or country [setup guide]
  • encrypt access to a directory with a password [setup in the WebAdmin]
  • automatically set so-called nice URL (name-document.html) [external guide for setup]
  • turning on and off browsing directories [can be set up in the WebAdmin]
  • sett a different default file instead of index.html/index.php
  • compression or caching of files (different regarding the type of application or CMS)
Updated on September 19, 2024

Was this article helpful?

Related Articles