Knowledge Base

.htaccess Guide

Overview

An .htaccess file contains directives that the web server will apply before page is displayed.
This means that a .htaccess file may allow or restrict access to files or directories, redirect to different resources or even change PHP-Configuration.
 

This is achieved by directives. A directive consists of a directive name and value.
Examples: 

  • DirectoryOptions +Indexes
  • phpflag display_errors on

 

Order of Directives

 

 

Before making any changes, it is important to consider how these rules are applied.
When a request is processed the web-server looks for a .htaccess file in the directory from which the content is served.
When found, any directives in this file are applied in their order within the file.
The server will then backtrack down each directory until it reaches the web-root (ie: /var/www) applying all rules from .htaccess files it finds along the way.

 

Setting directives

To get started you can create a plain-text file named .htaccess. Upload it to the document root, or a folder from which requests are served that you wish to modify.
(This can be also be done from within the ControlPanel=>File-Manager).

 

Each directive placed on a separate line. Examples of valid directives:

  • Options +Indexes
  • RewriteCond %{HTTPS} ^ON$
  • php_value error_reporting 99999
  • phpflag display_errors on

 

More Examples can be found in the Apache Web-Server Documentation located at: https://httpd.apache.org/docs/current/howto/htaccess.html

Please rate this article to help us improve our Knowledge Base.

0 0

a brand of Sebastian-Wilhelm Graf

Premium IT-Services

Proud Member: