Apache HTTP Server is the most commonly used web server software for dedicated servers. One of its features that makes it particularly versatile is the ability to add directives to the configuration file. System administrators can add directives to the server’s primary configuration file, and the sys admin can also use a directive to grant individual directive privileges to users by way of .htaccess files on shared hosting accounts.
To edit or add directives, you will need root access to the server. Login as root by typing “su” from the command line. When prompted, enter the root password.
Next, find the Apache configuration file. On Red Hat-based Linux servers, such as CentOS, it can be found in: /etc/httpd/conf/httpd.conf
On Debian GNU/Linux-based servers, the configuration file is located at: /etc/apache2/apache2.conf
Directives have the following format: DirectiveName Variable
The directive name usually has the first letter of each word capitalized, and the name never has spaces. The variable may be a boolean indicator, integer, or string. For example, the Bind Address directive would look like:
On the other hand, the Error Document directive has three components: the directive, the error code, and the URL to the document. For example:
ErrorDocument 404 http://www.domain.tld/errordocs/404.html
Directives added to the Apache configuration file will affect the entire server. After you add these global directives, you will need to restart Apache for the directives to take effect.
/etc/init.d/httpd restart OR /etc/init.d/apache2 restart
For local directives, you need to place the .htaccess file in the directory that the user wants to be affected by the directive. Directives in .htaccess files take effect immediately. Therefore, be sure they are configured correctly before saving the file.
There are hundreds of Apache directives at your disposal. For a complete list, see the Apache Directive Quick Reference.